mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
close_tx: initialize fee and input amount fields.
Required for alpha. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
90e4160862
commit
1075264c66
@ -12,6 +12,7 @@ struct bitcoin_tx *create_close_tx(const tal_t *ctx,
|
||||
OpenChannel *theirs,
|
||||
int64_t delta,
|
||||
const struct sha256_double *anchor_txid,
|
||||
uint64_t input_amount,
|
||||
unsigned int anchor_output)
|
||||
{
|
||||
struct bitcoin_tx *tx;
|
||||
@ -25,6 +26,7 @@ struct bitcoin_tx *create_close_tx(const tal_t *ctx,
|
||||
/* Our input spends the anchor tx output. */
|
||||
tx->input[0].txid = *anchor_txid;
|
||||
tx->input[0].index = anchor_output;
|
||||
tx->input[0].input_amount = input_amount;
|
||||
|
||||
/* Outputs goes to final pubkey */
|
||||
if (!proto_to_pubkey(ours->final, &ourkey))
|
||||
@ -52,6 +54,7 @@ struct bitcoin_tx *create_close_tx(const tal_t *ctx,
|
||||
tx->output[1].script = scriptpubkey_p2sh(tx, redeemscript);
|
||||
tx->output[1].script_length = tal_count(tx->output[1].script);
|
||||
|
||||
tx->fee = ours->commitment_fee + theirs->commitment_fee;
|
||||
permute_outputs(ours->seed, theirs->seed, 1, tx->output, 2, NULL);
|
||||
return tx;
|
||||
}
|
||||
|
@ -12,5 +12,6 @@ struct bitcoin_tx *create_close_tx(const tal_t *ctx,
|
||||
OpenChannel *theirs,
|
||||
int64_t delta,
|
||||
const struct sha256_double *anchor_txid,
|
||||
uint64_t input_amount,
|
||||
unsigned int anchor_output);
|
||||
#endif
|
||||
|
@ -32,7 +32,7 @@ int main(int argc, char *argv[])
|
||||
struct pubkey pubkey1, pubkey2;
|
||||
u8 *redeemscript;
|
||||
int64_t delta;
|
||||
size_t i;
|
||||
size_t i, anchor_out;
|
||||
|
||||
err_set_progname(argv[0]);
|
||||
|
||||
@ -81,9 +81,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Now create the close tx to spend 2/2 output of anchor. */
|
||||
/* Assumes that updates are all from closer -> closee */
|
||||
anchor_out = find_p2sh_out(anchor, redeemscript);
|
||||
close_tx = create_close_tx(ctx, o1, o2, complete ? -delta : delta,
|
||||
&anchor_txid,
|
||||
find_p2sh_out(anchor, redeemscript));
|
||||
&anchor_txid,
|
||||
anchor->output[anchor_out].amount,
|
||||
anchor_out);
|
||||
|
||||
/* Sign it for them. */
|
||||
sign_tx_input(ctx, close_tx, 0, redeemscript, tal_count(redeemscript),
|
||||
|
@ -28,7 +28,7 @@ int main(int argc, char *argv[])
|
||||
u8 *redeemscript;
|
||||
CloseChannel *close;
|
||||
CloseChannelComplete *closecomplete;
|
||||
size_t i;
|
||||
size_t i, anchor_out;
|
||||
int64_t delta;
|
||||
|
||||
err_set_progname(argv[0]);
|
||||
@ -69,8 +69,10 @@ int main(int argc, char *argv[])
|
||||
redeemscript = bitcoin_redeem_2of2(ctx, &pubkey1, &pubkey2);
|
||||
|
||||
/* Now create the close tx to spend 2/2 output of anchor. */
|
||||
anchor_out = find_p2sh_out(anchor, redeemscript);
|
||||
close_tx = create_close_tx(ctx, o1, o2, delta, &anchor_txid,
|
||||
find_p2sh_out(anchor, redeemscript));
|
||||
anchor->output[anchor_out].amount,
|
||||
anchor_out);
|
||||
|
||||
/* Signatures well-formed? */
|
||||
sig1.stype = sig2.stype = SIGHASH_ALL;
|
||||
|
Loading…
Reference in New Issue
Block a user