watch: indicate which input of tx is spend the watch txo.

If we generate a tx which spends a heap of TXOs (eg. steal
transaction), we'll need this.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2016-05-03 11:00:20 +09:30
parent 9eabab78ab
commit 77a89bcf2b
4 changed files with 18 additions and 5 deletions

View File

@@ -754,11 +754,18 @@ static void close_depth_cb(struct peer *peer, int depth,
* invalid transactions! */
static void anchor_spent(struct peer *peer,
const struct bitcoin_tx *tx,
size_t input_num,
void *unused)
{
struct anchor_watch *w = peer->anchor.watches;
union input idata;
assert(input_num < tx->input_count);
/* We only ever sign single-input txs. */
if (input_num != 0)
fatal("Anchor spend by non-single input tx");
/* FIXME: change type in idata? */
idata.btc = (struct bitcoin_event *)tx;
if (is_unrevoked_commit(peer->them.commit, tx))
@@ -867,6 +874,7 @@ static void commit_tx_depth(struct peer *peer, int depth,
/* We should map back from commit_tx permutation to figure out what happened. */
static void our_commit_spent(struct peer *peer,
const struct bitcoin_tx *commit_tx,
size_t input_num,
struct commit_info *info)
{
/* FIXME: do something useful here, if HTLCs spent */