withdraw: refactor change output handling

We're not using the change_outnum for withdraw tx's (and the way
we were calculating it was broken as of the addition of 'multiple
outputs'). This removes the change output knowhow from withdraw_tx
entirely, and pushes the responsibility up to the caller to
include the change output in the output set if desired.

Consequently, we also remove the change output knowhow from hsmd.
This commit is contained in:
lisa neigut
2019-09-16 19:08:05 -05:00
committed by Christian Decker
parent 09815c7e7f
commit 16656a85cf
8 changed files with 39 additions and 67 deletions

View File

@@ -32,6 +32,16 @@ int wally_tx_clone(struct wally_tx *tx, struct wally_tx **output)
return ret;
}
struct bitcoin_tx_output *new_tx_output(const tal_t *ctx,
struct amount_sat amount,
const u8 *script)
{
struct bitcoin_tx_output *output = tal(ctx, struct bitcoin_tx_output);
output->amount = amount;
output->script = tal_dup_arr(output, u8, script, tal_count(script), 0);
return output;
}
int bitcoin_tx_add_output(struct bitcoin_tx *tx, const u8 *script,
u8 *wscript, struct amount_sat amount)
{

View File

@@ -35,6 +35,10 @@ struct bitcoin_tx_output {
u8 *script;
};
struct bitcoin_tx_output *new_tx_output(const tal_t *ctx,
struct amount_sat amount,
const u8 *script);
/* SHA256^2 the tx in legacy format. */
void bitcoin_txid(const struct bitcoin_tx *tx, struct bitcoin_txid *txid);
void wally_txid(const struct wally_tx *wtx, struct bitcoin_txid *txid);