Commit Graph

7890 Commits

Author SHA1 Message Date
niftynei 8fa04a710a psbt: move `channels.last_tx` field to be a psbt
note: missing migration at the moment lol
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
Rusty Russell d737b54625 bitcoin/tx: implement wally_tx_clone (badly) for now.
When libwally exposes it, we can use theirs.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-06-11 13:13:13 +02:00
niftynei f9300e8480 tx: add setter for tx locktime
We need to update the psbt's global transaction simultaneously, so we
wrap access to the locktime in a method which will handle both
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 894a46e8e3 psbt: populate last commitment transaction's input info at db
when re-populating a channel's data from the database, since we don't
store the psbt data (with input scripts + amounts), we need to
re-populate it.

the right solution is to patch the psbt into the database; for now we
'monkey-patch' it in.
2020-06-11 13:13:13 +02:00
niftynei 7969f61ab3 tx: update comment
Make comment a bit more descriptive / usefu
2020-06-11 13:13:13 +02:00
niftynei dc868630a8 tx-psbt: pass in the witness script (if known) when adding an input
Update the `bitcoin_tx_add_input` interface to accept a witness script
and or scriptPubkey.

We save the amount + witness script + witness program (if known) to
the PSBT object for a transaction when creating an input.
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 85f395f7d4 utxo: fill in scriptPubkey to NULL
We need this so we can access it when populating bitcoin inputs in the
next commit
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 6197bd2b82 psbt: check return value on init for wally input 2020-06-11 13:13:13 +02:00
niftynei 1d56a4eda1 libwally: update to latest commit 2020-06-11 13:13:13 +02:00
Rusty Russell 0f568e1861 hsmd: remove unused sign_funding_tx.
We always treat it as a withdrawl.

Reported-by: @niftynei
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-06-02 08:47:31 +02:00
niftynei 27e83f075f doc: remove bitcoin PPA from install instructions, use snap
the PPA is no longer maintained, the new hotness is the snapd install.
except that snapd does some weirdness with the binary names, calling it
bitcoin-core.daemon and bitcoin-core.cli. To get around this, you can
create a symbolic link to the snap binaries, which is what we outline
here.
2020-06-01 23:18:15 +02:00
niftynei 185fe722be update-mocks: make it a bit easier to tell what step is happening
Adding a small explainer before printing the filename makes it a bit
clearer what's going on when parsing make logs
2020-05-30 15:36:56 +02:00
niftynei 76c57595c3 tools-make: add mock parser for clang ld output
According to #3226, it looks like clang's LD error format has changed.
This patch adds the new format so we can parse the mocks successfully.

Apple clang version 11.0.3 (clang-1103.0.32.29)

```
checking for ANSI C header files... Undefined symbols for architecture x86_64:
  "_fromwire_amount_msat", referenced from:
      _fromwire_tlv_test_n1_tlv3 in ccj4zKdV.o
  "_fromwire_bool", referenced from:
      _fromwire_test_msg in ccj4zKdV.o
      _fromwire_test_msg_option_short_id in ccj4zKdV.o
      _fromwire_test_msg_option_one in ccj4zKdV.o
      _fromwire_test_msg_option_two in ccj4zKdV.o
  "_fromwire_test_enum", referenced from:
      _fromwire_test_msg in ccj4zKdV.o
      _fromwire_test_msg_option_short_id in ccj4zKdV.o
      _fromwire_test_msg_option_one in ccj4zKdV.o
      _fromwire_test_msg_option_two in ccj4zKdV.o
  "_fromwire_tlvs", referenced from:
      _fromwire_test_tlv1 in ccj4zKdV.o
      _fromwire_test_tlv2 in ccj4zKdV.o
      _fromwire_test_tlv3 in ccj4zKdV.o
  "_fromwire_tu32", referenced from:
      _fromwire_tlv_test_n2_tlv2 in ccj4zKdV.o
  "_fromwire_tu64", referenced from:
      _fromwire_tlv_test_n1_tlv1 in ccj4zKdV.o
      _fromwire_tlv_test_n2_tlv1 in ccj4zKdV.o
  "_fromwire_u16", referenced from:
      _fromwire_test_features in ccj4zKdV.o
      _fromwire_subtype_var_assign in ccj4zKdV.o
      _fromwire_subtype_arrays in ccj4zKdV.o
      _fromwire_tlv_test_n1_tlv4 in ccj4zKdV.o
      _fromwire_tlv_test_n3_tlv3 in ccj4zKdV.o
      _fromwire_test_msg in ccj4zKdV.o
      _fromwire_test_tlv1 in ccj4zKdV.o
      ...
  "_fromwire_u32", referenced from:
      _fromwire_tlv_test_n3_tlv3 in ccj4zKdV.o
      _fromwire_test_msg in ccj4zKdV.o
      _fromwire_test_msg_option_short_id in ccj4zKdV.o
      _fromwire_test_msg_option_one in ccj4zKdV.o
      _fromwire_test_msg_option_two in ccj4zKdV.o
  "_fromwire_u64", referenced from:
      _fromwire_test_short_id in ccj4zKdV.o
      _fromwire_tlv_test_n3_tlv3 in ccj4zKdV.o
  "_fromwire_u8", referenced from:
      _fromwire_subtype_var_assign in ccj4zKdV.o
      _fromwire_subtype_var_len in ccj4zKdV.o
      _fromwire_subtype_varlen_varsize in ccj4zKdV.o
      _fromwire_tlv_test_n3_tlv3 in ccj4zKdV.o
  "_fromwire_u8_array", referenced from:
      _fromwire_test_features in ccj4zKdV.o
      _fromwire_subtype_arrays in ccj4zKdV.o
      _fromwire_tlv_test_n3_tlv3 in ccj4zKdV.o
      _fromwire_test_msg in ccj4zKdV.o
      _fromwire_test_msg_option_short_id in ccj4zKdV.o
      _fromwire_test_msg_option_one in ccj4zKdV.o
      _fromwire_test_msg_option_two in ccj4zKdV.o
      ...
```

Changelog-Fixed: Build for macOS Catalina / Apple clang v11.0.3 fixed
2020-05-30 15:36:56 +02:00
niftynei 3640befc10 tools-make: also be quiet if --quiet is flagged
Missed a update-mocks.sh call
2020-05-30 15:36:56 +02:00
niftynei 24e186bc20 test: use correct deps for channeld tests
LIGHTNING_CHANNELD_* doesn't exist; the actual name is
LIGHTNINGD_CHANNEL_*
2020-05-29 16:20:23 -05:00
niftynei 78d95b51aa nit: align spacing for SQL stmts 2020-05-29 16:20:23 -05:00
fiatjaf 96452eafb7 sort listinvoices and listsendpays by order of creation. 2020-05-29 15:30:59 +02:00
Rusty Russell ce9e559aed features: do not set option_support_large_channel in channel_announcement.
Spec is wrong (it says it should be compulsory), and Eclair doesn't set it
at all, leading to an error when they send their announcement_signatures.

Fixes: #3703
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Changelog-changed: large-channels: negotiate successfully with Eclair nodes.
2020-05-26 19:57:29 -05:00
Rusty Russell b3eef81f19 pytest: add test for channel_announcement feature bits.
And neaten current feature mangling code now we have a wumbo flag for
expected_peer_features().

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-26 19:57:29 -05:00
Rusty Russell 4d917e2566 gossipd: add test showing how we and Eclair disagree on channel_announcement features for wumbo channels.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-26 19:57:29 -05:00
Rusty Russell f4f8a363dd pytest: fix feature mask for EXPERIMENTAL_FEATURES, add wumbo support.
There are various places where our tests failed with
--enable-expimental-features.  And our plugin test overlapped an
existing feature.

We make our expected_feature functions more generic, and use them
everywhere.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-26 19:57:29 -05:00
Rusty Russell 0b89664076 gossipd: fix cut & paste in error messages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-26 19:57:29 -05:00
Rusty Russell 0b3040b9a6 bitcoin/tx: insist input amounts all be populated across the wire.
If you need to send a tx where you don't know this info, send a tx_parts.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell 1e889eeaf7 lightningd: have sign_last_tx populate the input amounts.
With this change, all bitcoin_tx we send across the wire have
their inputs_amounts populated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell 48853ec954 onchaind: use tx_parts for initial tx.
For the moment it's a complete tx, but in future designs we might only
be given the specific input which closes the channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell abba59057c onchaind: remove chainparams args in favor of global.
Otherwise this creates noise for the next patch which switches the initial
`struct bitcoin_tx` into a `struct tx_parts`.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell 48f397ee19 onchaind: receive a tx_parts instead of a tx when a tx is seen onchain.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell dafaf854c5 bitcoin/tx_parts: infrastructure for partial bitcoin txs.
`struct tx_parts` is just a txid and a bunch of inputs and outputs,
some of which may be NULL.

This is both a nod towards a future where we (or our peer) can combine
HTLCs or (in an eltoo world) commitments, although for the moment all
our tx_parts will be complete.

It also matches our plan to split `bitcoin_tx` into two types: this
`struct tx_parts` where we don't know input amounts etc, and `psbt`
where we do.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Rusty Russell 7e48f77d43 bitcoin/tx: expose functions for raw wally_txs.
These are useful for tx_parts:

1. wally_txid.
2. linearize_wtx.
3. wally_tx_input_spends
4. wally_tx_output_get_amount
5. wally_tx_input_get_txid

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2020-05-27 10:12:03 +09:30
Glen Cooper 8d98b99bde Update TOR.md
typo: referes, changed to refer
2020-05-26 12:21:40 +09:30
Antoine Poinsot 5dfd2436db wallet: show input txid in little endian for json_listtransactions
Changelog-Fixed: jsonrpc: `listtransactions` now displays all txids as little endian

Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-05-22 15:11:51 +02:00
Antoine Poinsot 1061cd95c9 pytest: add a sanity check for the listtransactions command
Signed-off-by: Antoine Poinsot <darosior@protonmail.com>
2020-05-22 15:11:51 +02:00
lisa neigut 1fb9a078b6 txprepare: return psbt serialized version of tx as well
Changelog-Added: JSON-API: `txprepare` returns a psbt version of the created transaction
2020-05-21 18:45:07 +09:30
niftynei bf4cac7fb8 tx: strip out witscript
now that witness script data is saved into the tx/psbt which is
serialized across the wire, there's no reason to use witscript to do
this. good bye witscript!
2020-05-21 18:45:07 +09:30
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 a848df67f1 psbt: populate scriptsigs + witnesses
Pass scriptSig + witness info down to the PSBT struct
2020-05-21 18:45:07 +09:30
niftynei 2055b53425 psbt: update global tx output amount also 2020-05-21 18:45:07 +09:30
niftynei cf9de86dba psbt: add transaction inputs to the psbt struct
Make sure that we permute them also!

Fixes weird spacing also
2020-05-21 18:45:07 +09:30
niftynei a1e1073752 tx: move to tal_dup_arr 2020-05-21 18:45:07 +09:30
niftynei b076f40cf3 psbt: move witness script storage into the psbt
we can now keep associated witness data with the output in the psbt
struct, so we do that.
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
niftynei 7a0624797e psbt: add psbt to bitcoin tx struct 2020-05-21 18:45:07 +09:30
niftynei 24ecb3e2b9 Remove trailing line in fromwire.c 2020-05-21 18:45:07 +09:30