Make cppcheck happy and code clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2018-03-29 12:29:27 +10:30 committed by Christian Decker
parent 760e9f6993
commit b45477b081
2 changed files with 14 additions and 8 deletions

View File

@ -610,7 +610,7 @@ static void sign_funding_tx(struct daemon_conn *master, const u8 *msg)
struct bitcoin_tx *tx;
u16 outnum;
size_t i;
struct pubkey changekey;
const struct pubkey *changekey;
u8 **scriptSigs;
/* FIXME: Check fee is "reasonable" */
@ -620,13 +620,16 @@ static void sign_funding_tx(struct daemon_conn *master, const u8 *msg)
&remote_pubkey, &utxomap))
master_badmsg(WIRE_HSM_SIGN_FUNDING, msg);
if (change_out)
bitcoin_pubkey(&changekey, change_keyindex);
if (change_out) {
changekey = tal(tmpctx, struct pubkey);
bitcoin_pubkey(changekey, change_keyindex);
} else
changekey = NULL;
tx = funding_tx(tmpctx, &outnum,
cast_const2(const struct utxo **, utxomap),
satoshi_out, &local_pubkey, &remote_pubkey,
change_out, &changekey,
change_out, changekey,
NULL);
scriptSigs = tal_arr(tmpctx, u8*, tal_count(utxomap));

View File

@ -214,7 +214,8 @@ static u8 *funder_channel(struct state *state,
u8 *msg;
struct bitcoin_tx *tx;
struct basepoints theirs;
struct pubkey their_funding_pubkey, changekey;
struct pubkey their_funding_pubkey;
const struct pubkey *changekey;
secp256k1_ecdsa_signature sig;
u32 minimum_depth;
const u8 *wscript;
@ -322,17 +323,19 @@ static u8 *funder_channel(struct state *state,
/* Now, ask create funding transaction to pay those two addresses. */
if (change_satoshis) {
if (!bip32_pubkey(bip32_base, &changekey, change_keyindex))
changekey = tal(tmpctx, struct pubkey);
if (!bip32_pubkey(bip32_base, changekey, change_keyindex))
status_failed(STATUS_FAIL_MASTER_IO,
"Bad change key %u", change_keyindex);
}
} else
changekey = NULL;
funding = funding_tx(state, &state->funding_txout,
cast_const2(const struct utxo **, utxos),
state->funding_satoshis,
our_funding_pubkey,
&their_funding_pubkey,
change_satoshis, &changekey,
change_satoshis, changekey,
bip32_base);
bitcoin_txid(funding, &state->funding_txid);