Commit Graph

5639 Commits

Author SHA1 Message Date
Christian Decker 21a0dad016 wally: Post-migration cleanups
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 509bb2c7ae wally: Remove tx->input and tx->output, wally all the way!
This is what all of this has been working towards: ripping out the handwoven
transaction handling. By removing the custom parsing we can finally switch
over to using `wally_tx` as sole representation of transactions in
memory. The commit is a bit larger but it's mostly removing setters and old
references to the input and output fields.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker cf9f484168 wally: Migrate channeld over to use libwally
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker d651ce6f3b wally: Migrate main daemon to use wally transactions
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker c39963b8b7 wally: Migrate hsmd to use the wally tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 50ade7349f wally: Migrate onchaind to use the wally tx and the helpers
Weaning `onchaind` off its use of the internal bitcoin_tx input and output
fields, since we're going to remove them soon, I promise.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 8d0500228e wally: Add accessor methods for script and amount
These are handled internally in the `wally_tx` and do not conform to our usual
tallocated strings that can by inspected using `tal_bytelen`, and we don't
really want to litter our code with whitelisting comments for the
`amount_sat.satoshis` access, so these just do read-only on the fly conversions.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 64273b5ec5 wally: Migrate permute_tx to be wally_tx first
This is the second to last time I'm touching this file, just need to remove
the `tx->input` and `tx->output` swapping once they are removed.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 30ed2e1a8f wally: Remove unused sha256_tx_for_sig function
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 3ae19479a8 wally: Use libwally only to serialize transactions
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 9fe481b967 wally: Move input amounts into a separate array
The `wally_tx_input`s do not keep track of their input value, which means we
need to track them ourselves if we try to sign these transactions at a later
point in time.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 48006cb674 wally: Switch signatures over to using the wally_tx hash
First step towards decomissioning the handrolled bitcoin_tx operations.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker cc31efd0e8 wally: Migrate run-tx-encode to directly access the wally_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker ce58cba9fe wally: Making extra sure that pulling a TX results in the correct read offset. 2019-04-08 00:00:00 +00:00
Christian Decker 4f0c386d32 wally: Use input and output setters in onchaind and htlc_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 369a85e289 wally: Use output and input setters when signing / grinding feerate
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 03329a61da wally: Add setters for output amounts, input witnesses and scripts
These are used when grinding the feerate and signing. These are just simple
facades that keep both wally and old style transactions in sync.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 73ab7e6d5f wally: Migrate htlc_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker bd2573eafb wally: Build wally transactions in parallel with the old ones
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker b0c31a14c1 wally: Migrate close_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 0c962fdc29 wally: Migrate commit_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 41eea5f40c wally: Migrate initial_commit_tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 12ec8dc137 wally: Migrate the withdraw transaction
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 710a2abc5f wally: Migrate the funding transaction
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 3937b17e2b wally: Add a consistency check for old and new style txs
During the migration to `libwally` we want to make absolutely sure that both
transactions are generated identical, and can eventually be switched over.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 98983006d6 wally: Migrate the funding transaction to use the shims
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 7e03db5062 tx: Change permute_{inputs,outputs} to sort both old and new txs
This is required in order for both old and new transactions to be identical.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 60fbf1f7d0 wally: Add shims to generate both transaction versions in parallel
We are slowly migrating towards a wally-transactions only world, but to make
this reviewable we start building both old and new style transactions in
parallel. In a second pass we'll then start removing the old ones and use
libwally only.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 16f72cb160 wally: Migrate version and locktime to libwally tx
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
Christian Decker 9609d762c8 wally: Add wally_tx in bitcoin_tx
Allows us to slowly migrate individual parts.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2019-04-08 00:00:00 +00:00
trueptolemy 92b40cb68a fix:Add infor about how many blocks needed until funding is confirmed
1. Rename channel_funding_locked to channel_funding_depth in
channeld/channel_wire.csv.
2. Add minimum_depth in struct channel in common/initial_channel.h and
change corresponding init function: new_initial_channel().
3. Add confirmation_needed in struct peer in channeld/channeld.c.
4. Rename channel_tell_funding_locked to channel_tell_depth.
5. Call channel_tell_depth even if depth < minimum, and still call
lockin_complete in channel_tell_depth, iff depth > minimum_depth.
6. channeld ignore the channel_funding_depth unless its >
minimum_depth(except to update billboard, and set
peer->confirmation_needed = minimum_depth - depth).
2019-04-07 23:45:35 +00:00
trueptolemy d140e927bf Add comments of BOLT quote about 'htlc_maximum_mast' bound
s channeld.c

s channeld.c
2019-04-06 21:55:26 -07:00
andrewtoth 90f9985dd2 Update disconnect manpage 2019-04-04 15:13:47 +02:00
andrewtoth 365dcb211f Update getroute helptext 2019-04-04 15:13:47 +02:00
Rusty Russell dda000fe2d unittest: make sure VALGRIND env var set under valgrind.
In particular, `make unittest/bitcoin/test/run-secret_eq_consttime`
didn't set VALGRIND if it was set via config.vars, so runs for a *long*
time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2019-04-04 15:12:08 +02:00
lisa neigut bad0ac6ed6 tlv: use `var_int`s for size of messages
TLV's use var_int's for messages sizes, both internally and
in the top level (you should really stack a var_int inside a var_int!!)

this updates our automagick generator code to understand 'var_ints'
2019-04-03 03:15:42 +00:00
lisa neigut 74ae9f09ac wire: add var_int parsing functions
so we can put and pull bitcoin 'var_int' length types from the
wire.

for more info on variable integers, see http://learnmeabitcoin.com/glossary/varint
2019-04-03 03:15:42 +00:00
lisa neigut 1213f44071 tlv: adapt to work with new output format
Updated to match what the CSV generator in the RFC repo actually
outputs, see https://github.com/lightningnetwork/lightning-rfc/pull/597
2019-04-03 03:15:42 +00:00
lisa neigut df9774c2be tlv: fixup FIXME -- remove comments + use includes
include includes for TLV _csv files
2019-04-03 03:15:42 +00:00
lisa neigut 5d8b059ccc tlv: free intermediate messages when they're created
otherwise they'll get cleaned up when the message is free'd.
it's nbd either way, but this seems tighter.
2019-04-03 03:15:42 +00:00
lisa neigut 4afcc2e5a8 tlv: fixup parsing for multi-message tlv's
need to pass in a pointer to the array so that when we advance
the array in the subcalls, it advances in the parent. oops
2019-04-03 03:15:42 +00:00
lisa neigut d0f50c8690 tlv: fail if parsed length doesn't match packet length 2019-04-03 03:15:42 +00:00
lisa neigut 28c3f9ca21 tlv: don't crash when you fail to parse the TLV
passing back a null TLV was crashing here, because we tried to
dereference a null pointer. instead, we put it into a temporary
struct that we can check for NULL-ness, before assigning to the
passed in pointer.
2019-04-03 03:15:42 +00:00
lisa neigut d8738452ed tlv: it's ok to be odd
fail if a message type is even and it's not included. otherwise,
continue with the next message type.
2019-04-03 03:15:42 +00:00
lisa neigut b89ea071e8 tlv: allocate tlv structs from within
let's let the fromwire__tlv methods allocate the tlv-objects and
return them. we also want to initialize all of their underlying
messages to NULL, and fail if we discover a duplicate mesage type.

if parsing fails, instead of returning a struct we return NULL.

Suggested-By: @rustyrussell
2019-04-03 03:15:42 +00:00
lisa neigut 5aea65b463 tlv: make message sizes u8 not u16
Suggested-By: @rustyrussell
2019-04-03 03:15:42 +00:00
lisa neigut d6332997bd tlv: remove leading '_' from things
Suggested-By: @rustyrussell
2019-04-03 03:15:42 +00:00
lisa neigut aba4e161ce tlv: calculate sizeof by measuring message length
much better than statically calculating the sizeof
2019-04-03 03:15:42 +00:00
lisa neigut 9a23a354fd tlv: consolidate basetype parsing
clean up basetype parsing code a bit
2019-04-03 03:15:42 +00:00
lisa neigut 6f2e70a6ac tlv: add fromwire_ methods for TLV structs 2019-04-03 03:15:42 +00:00