utils: use a cleaner pattern to capture wally allocations.

We force use of tal_wally_start/tal_wally_end around every wally
allocation, and with "end" make the caller choose where to reparent
everything.

This is particularly powerful where we allocate a tx or a psbt: we
want that tx or psbt to be the parent of the other allocations, so
this way we can reparent the tx or psbt, then reparent everything
else onto it.

Implementing psbt_finalize (which uses a behavior flag antipattern)
was tricky, so I ended up splitting that into 'psbt_finalize' and
'psbt_final_tx', which I think also makes the callers clearer.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-09-23 20:13:28 +09:30
committed by Christian Decker
parent 66ffd7a73f
commit d5cb0d85b5
15 changed files with 225 additions and 148 deletions

View File

@@ -614,7 +614,7 @@ openchannel2_sign_hook_cb(struct openchannel2_psbt_payload *payload STEALS)
tal_steal(tmpctx, payload);
/* Finalize it, if not already. It shouldn't work entirely */
psbt_finalize(tmpctx, payload->psbt, true);
psbt_finalize(payload->psbt);
if (!psbt_side_finalized(payload->ld->log, payload->psbt, REMOTE))
fatal("Plugin must return a 'psbt' with signatures for their inputs"