Rusty Russell
c23001d508
bitcoin: use tal_gather_wally() so we don't leave unattached allocations.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
3c8049f32c
bitcoin/psbt: psbt_input_add_unknown/psbt_output_add_unknown needs a tal ctx.
Since it allocates something, it needs a context (used in the next patch!).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
77b62d9e42
bitcoin/psbt: psbt_finalize needs a tal ctx.
Since it returns a wally_tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
607075a3d4
bitcoin/psbt: wallt_tx_output needs a tal ctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
480f671e91
bitcoin/psbt: psbt_txid needs a tal ctx.
It returns a wally_tx; it's an anti-pattern not to hand in a tal context.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
11ebb84e7d
bitcoin/psbt: attach destructors to wally allocations to avoid leaks.
This covers the obvious ones, but the later patches fix this more
seriously.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-Fixed: Some memory leaks in transaction and PSBT manipulate closed.
4 years ago
Rusty Russell
80c705d528
bitcoin/psbt: more const pointers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
niftynei
165d039f6c
elements: consolidate fee outputs into a single fee output
In the case that you've got more than one fee output already on a
psbt, we consolidate them into a single fee output (the first)
4 years ago
niftynei
4c28e7b362
txprepare: elements requires inclusion of an accurate fee output
so we add an accurate one
4 years ago
niftynei
24578c7fea
elementsd: use the elements version of a 'witness utxo'
Elements requires the witness utxo to include the asset and value info,
in order for the signing hash to be constructed correctly
Changelog-Fixed: elementsd: PSBTs include correct witness_utxo struct for elements transactions
4 years ago
ZmnSCPxj jxPCSnmZ
5d7178d488
bitcoin/psbt.c: Add psbt_insert_output function.
4 years ago
niftynei
303263d381
psbt: clean up interface for setting metadata on PSBT inputs
it's just neater if it's not all wrapped up together, simplifies the
interface a smidge
4 years ago
niftynei
0305c0a57e
psbt: if psbt is null, return null for get_bytes
4 years ago
niftynei
10237ccb8e
psbt: handle 'NULL' or empty byte PSBTs
Don't crash if the PSBT is null / zero-byte len.
4 years ago
Rusty Russell
6e4e267f2c
doc: update BOLT now option_anchor_outputs is merged.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
a0ede40743
bitcoin: make psbt_append_input more powerful.
It can now handle all the metadata as well as the base tx input.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
172b9d7ae3
bitcoin: add nlocktime arg to create_psbt.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
niftynei
c6656dcbe8
psbt: use elements input init alloc
4 years ago
niftynei
2f9a37de4a
psbt: rename append_out -> append_output
4 years ago
niftynei
eef762cc09
psbt: re-use init function for create_psbt
Less code is more code!
4 years ago
niftynei
3923e0f0fd
psbt: utilities for adding unknown info / proprietary c-lightning keydata
5 years ago
niftynei
251cde3514
psbt: add helpers for creating + adding input/outputs
5 years ago
Rusty Russell
591e8f9663
psbt: finalize to-remote with option_anchor_outputs.
Until it gains miniscript support, wally doesn't know how to
finalize P2WSH. This happens with `option_anchor_outputs` for
to-remote, which requires a 1 block delay to force use of
anchor outputs for CPFP.
So we finalize this ourselves.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
a6a8a40594
psbt: implement psbt_txid.
You can't just take the txid of the global tx, if some are p2sh-wrapped.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Rusty Russell
600d0a4a1d
psbt: make psbt_from_b64 more conventional.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
Jon Griffiths
908a8399e2
psbt: Allocate correctly sized buffer for psbt_to_bytes
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
4 years ago
Jon Griffiths
fef155a9e2
psbt: Use wallys function to check PST finalization status
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
4 years ago
Jon Griffiths
1fe53880a7
psbt: use new wally functions to add PSBT inputs/outputs
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
4 years ago
Jon Griffiths
68ffecba63
psbt: Use the newly exposed wally function to clone PSBTs
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
4 years ago
Jon Griffiths
a51c6550ec
psbt: avoid allocations when adding psbt outputs
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
4 years ago
Jon Griffiths
499395636c
psbt: remove now-unneeded const casts
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
5 years ago
Jon Griffiths
95d3d65c62
wally: update to the latest wally version
Includes:
psbt: Use renamed functions for new wally version
psbt: Set the transaction directly to avoid script workarounds
psbt: Use low-S grinding when computing signatures
tx: Use wally_tx_clone from libwally now that its exported
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
5 years ago
Rusty Russell
ffbb409b47
amount: use initializers everywhere.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
4 years ago
niftynei
f5f85b389d
elements,pset: populate elements specific data for PSBTs
PSETs have a bit different requirements. The witness_utxo needs
the asset tag + values, and these should also be added to the PSET
struct separately as well. To do this, we create a new 'init' method for
elements inputs, which takes care of the elements specific things.
5 years ago
niftynei
4ecbd5f1a7
psbt: use pset initializer if needed
we're moving over to elements!
5 years ago
niftynei
175fcf381a
psbt: have wally_tx serialization methods be legible for gen'd code
our code generators expect the serialization name to match the struct
type
5 years ago
niftynei
b63abef542
psbt: add method to finalize + extract a psbt
will either use a temporary psbt (and not munge the passed in psbt)
or will finalize in place -- finalization erases most of the signature
metadata from the psbt struct
5 years ago
niftynei
0d1f1bc66e
psbt: add helper method for setting a psbt input's redeemscript
5 years ago
niftynei
c3ae44e296
psbt: don't crash if we can't add a partial sig
instead return a boolean indicating the success/failure of a sig set
5 years ago
niftynei
80072b389e
psbt: remove script sig info from inputs before adding them to global
PSBT's dont' serialize / unserialize if there's any sig info set on the
global transaction
5 years ago
niftynei
5ecacf3dd0
psbt: add type-to-string that prints b64 string
Re-uses code from what was the bitcoin_tx_to_psbt_b64
5 years ago
niftynei
58282819a9
psbt: if a transaction has witnesses/scriptSig set, add it to psbt
For any transaction that's got 'finalized' signature data for an input,
we should add this information to the psbt also
5 years ago
niftynei
052d40ae98
psbt: add method to confirm 'finalized' status of psbt
calling `wally_psbt_finalize` doesn't return a status indicator; instead
you must call `psbt_is_finalized` to check that it's eligible for
'extraction' -- extraction will fail if the psbt is not in a finalized
state.
5 years ago
niftynei
000ef2079c
psbt: helpers for adding a pubkey or signature to a psbt
we'll use these for the commitment txs!
5 years ago
niftynei
3c6e3eecee
psbt: add 'wally_psbt_clone' function, to clone a psbt
We'll need this for settng the tx correctly, for reasons
5 years ago
niftynei
db8ef922ed
psbt: add to/from byte helpers
We'll need these for the database methods we're going to add shortly
5 years ago
niftynei
a04f0fe250
psbt: remove input_amounts from bitcoin tx
Instead we will stash them into the PSBT as a utxo/witness record (which
includes the amount)
5 years ago
niftynei
cc6eba1d72
psbt: try one big alloc and fail instead of incremental buffer increases
was running into buffer overrun errors? something about the iteration
method was broken
5 years ago
niftynei
559f88faa1
psbt: add serialize to/from wire for psbts
5 years ago
niftynei
5d0fc176e8
psbt: create new_psbt method
Move all psbt creation into single method, new_psbt
note that if a psbt is init'd for a transaction that's
deserialized with scripts etc already attached, then set_global_tx
will fail. instead, we empty all of this out first.
if the tx is being re-init'd from a tx source that had a psbt attached
(e.g. fromwire_) then the script/witness data will get populated
appropriatel from there.
5 years ago