Browse Source

Make cppcheck happy and code clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 7 years ago
committed by Christian Decker
parent
commit
b45477b081
  1. 11
      hsmd/hsm.c
  2. 11
      openingd/opening.c

11
hsmd/hsm.c

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

11
openingd/opening.c

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

Loading…
Cancel
Save