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
2020-09-09 19:54:20 +09:30
niftynei
0305c0a57e
psbt: if psbt is null, return null for get_bytes
2020-08-25 12:34:56 +09:30
niftynei
10237ccb8e
psbt: handle 'NULL' or empty byte PSBTs
...
Don't crash if the PSBT is null / zero-byte len.
2020-08-25 12:34:56 +09:30
Rusty Russell
6e4e267f2c
doc: update BOLT now option_anchor_outputs is merged.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-24 20:55:47 +09:30
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>
2020-08-20 21:14:12 +09:30
Rusty Russell
172b9d7ae3
bitcoin: add nlocktime arg to create_psbt.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-20 21:14:12 +09:30
niftynei
c6656dcbe8
psbt: use elements input init alloc
2020-08-18 11:08:44 +09:30
niftynei
2f9a37de4a
psbt: rename append_out -> append_output
2020-08-18 11:08:44 +09:30
niftynei
eef762cc09
psbt: re-use init function for create_psbt
...
Less code is more code!
2020-08-18 11:08:44 +09:30
niftynei
3923e0f0fd
psbt: utilities for adding unknown info / proprietary c-lightning keydata
2020-08-18 11:08:44 +09:30
niftynei
251cde3514
psbt: add helpers for creating + adding input/outputs
2020-08-18 11:08:44 +09:30
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>
2020-08-14 11:51:14 +09:30
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>
2020-08-11 08:39:24 +09:30
Rusty Russell
600d0a4a1d
psbt: make psbt_from_b64 more conventional.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-11 08:39:24 +09:30
Jon Griffiths
908a8399e2
psbt: Allocate correctly sized buffer for psbt_to_bytes
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
Jon Griffiths
fef155a9e2
psbt: Use wallys function to check PST finalization status
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
Jon Griffiths
1fe53880a7
psbt: use new wally functions to add PSBT inputs/outputs
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
Jon Griffiths
68ffecba63
psbt: Use the newly exposed wally function to clone PSBTs
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
Jon Griffiths
a51c6550ec
psbt: avoid allocations when adding psbt outputs
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
Jon Griffiths
499395636c
psbt: remove now-unneeded const casts
...
Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
2020-08-07 10:28:01 +09:30
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>
2020-08-07 10:28:01 +09:30
Rusty Russell
ffbb409b47
amount: use initializers everywhere.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-08-06 09:36:47 +09:30
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.
2020-07-13 11:37:24 +09:30
niftynei
4ecbd5f1a7
psbt: use pset initializer if needed
...
we're moving over to elements!
2020-07-13 11:37:24 +09:30
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
2020-06-23 14:49:32 +02:00
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
2020-06-23 14:49:32 +02:00
niftynei
0d1f1bc66e
psbt: add helper method for setting a psbt input's redeemscript
2020-06-23 14:49:32 +02:00
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
2020-06-23 14:49:32 +02:00
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
2020-06-23 14:49:32 +02:00
niftynei
5ecacf3dd0
psbt: add type-to-string that prints b64 string
...
Re-uses code from what was the bitcoin_tx_to_psbt_b64
2020-06-23 14:49:32 +02:00
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
2020-06-11 13:13:13 +02:00
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.
2020-06-11 13:13:13 +02:00
niftynei
000ef2079c
psbt: helpers for adding a pubkey or signature to a psbt
...
we'll use these for the commitment txs!
2020-06-11 13:13:13 +02:00
niftynei
3c6e3eecee
psbt: add 'wally_psbt_clone' function, to clone a psbt
...
We'll need this for settng the tx correctly, for reasons
2020-06-11 13:13:13 +02:00
niftynei
db8ef922ed
psbt: add to/from byte helpers
...
We'll need these for the database methods we're going to add shortly
2020-06-11 13:13:13 +02:00
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)
2020-06-11 13:13:13 +02:00
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
2020-06-11 13:13:13 +02:00
niftynei
559f88faa1
psbt: add serialize to/from wire for psbts
2020-05-21 18:45:07 +09:30
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.
2020-05-21 18:45:07 +09:30
niftynei
2d5c61dfc1
psbt: methods to mutate psbt in place
...
add the missing psbt helpers for adding and removing an input and output
2020-05-21 18:45:07 +09:30