Skip to content

PSBT Extensions and Elements PSBT Serialization - #201

Closed
achow101 wants to merge 24 commits into
ElementsProject:masterfrom
achow101:pset
Closed

PSBT Extensions and Elements PSBT Serialization#201
achow101 wants to merge 24 commits into
ElementsProject:masterfrom
achow101:pset

Conversation

@achow101

Copy link
Copy Markdown
Contributor

Implements the extensions to BIP 174 which add a global version field and proprietary types. The elements proprietary fields are implemented here too.

The elements PSBT fields are added to the psbt structs as well as their serialization and deserialization of those fields. None of the roles for elements psbt have been implemented as what they are supposed to do is still being worked out.

Based on #191

rustyrussell and others added 22 commits May 29, 2020 10:39
AFAICT, the below does the same thing, and avoids glslang having
to tell me to add my test there.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
As revealed by:

	make && LD_LIBRARY_PATH=`pwd`/src/.libs valgrind  --leak-check=full src/.libs/test_psbt

There are more, but the next patches rework that code.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Manually checking for end of buffers is error prone: these pull & push
variants are similar to those used by c-lightning.

Importantly, if they fail you can still call them, meaning you can
check whether it overflowed at the end of all the work.  The push
function also can tell you exactly how many bytes short you were.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This also means we return WALLY_EINVAL instead of corrupting the stack
if they provide a witness output > 50 bytes.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
As a special bonus, document that it now returns bytes_written as the
entire length, if the error was caused by bytes_len being insufficient.

This allows the caller to avoid calling bytes_len in the common case,
if they want to.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
…ytes.

This avoid (recently buggy!) duplication.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Now we pull the magic before calling count_psbt_parts(), it no longer
needs to skip over it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This currently fails (badly).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
valgrind is better, but this is simple and finds current leaks.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Byte vectors in a PSBT could have a 0 length and thus result in duplicate
keys in a PSBT as length 0 is also assumed that there is no vector for
that field. Instead of checking length, check that the pointer is non-null.

To ensure the pointers are non-null, malloc 1 byte. The length is still
stored as 0.
wally_psbt_elements_init_alloc is added to set an elements magic

wally_psbt_init_alloc, wally_psbt_to_bytes, and wally_psbt_from_bytes
are updated to deal with this magic instead of the hard coded magic.

wally_psbt_is_elements is added.
niftynei added 2 commits June 22, 2020 23:18
so it needs the bool header
libwally wants you to flag in what 'type' of transaction it's handling
in a few places (in others it seems to be able to figure it out for
itself)
This was referenced Jul 13, 2020
@jgriffiths

Copy link
Copy Markdown
Contributor

Closing this in favour of #210 which includes/supersedes it. Please re-open if something you need got missed in the merge.

@jgriffiths jgriffiths closed this Jul 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants