Commit Graph

9363 Commits

Author SHA1 Message Date
Rusty Russell
d51f6372aa update-channel: prepare a new tx with modified amounts.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-09 14:13:27 +09:30
Rusty Russell
ecb39efed1 find_p2sh_out: extract helper.
Really only for our silly little utils.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-09 14:13:21 +09:30
Rusty Russell
7175d73573 create-close-tx: create a mutual close tx from the close sigs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 15:08:10 +09:30
Rusty Russell
c6ed5926cb close-channel: add --complete option.
Code is identical, so don't create separate close-channel-complete binary.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 14:54:02 +09:30
Rusty Russell
38f7a23064 close-channel: create message to mutually close channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 14:46:41 +09:30
Rusty Russell
16baa1dae9 create-commit-spend-tx: spend the commit tx (after timeout)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 09:29:09 +09:30
Rusty Russell
114b7afbe2 bitcoin_script: fix bug in complex anchor redeem script.
We need to pop off the stack after OP_CHECKSEQUENCEVERIFY.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 09:26:14 +09:30
Rusty Russell
3a4d8cd282 bitcoin_script: use OP_NOP dummy for now, as bitcoind rejects OP_NOP3
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 09:24:54 +09:30
Rusty Russell
3c7e11fd65 bitcoin_script: DER correctly when we have leading zeroes.
Happens one in 128 times, I guess...

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 09:21:38 +09:30
Rusty Russell
a25ba452f3 permute_tx: fix horrible thinko.
Map needs to be inverted, otherwise non-trivial shuffles get confused.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 08:29:53 +09:30
Rusty Russell
4dd6b8e385 lightning.proto: Rename 'to_me' to 'final', use for commit_tx.
This is where the commit tx outputs should pay to.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 06:29:15 +09:30
Rusty Russell
baf5d11643 getinput.sh: Switch to -regtest
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-08 06:28:09 +09:30
Rusty Russell
9ed6968fe5 add_varint: encode correctly (LE)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-07 15:33:24 +09:30
Rusty Russell
0203d51ec0 pull_varint: fix.
Adapted badly from pettycoin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-07 15:32:34 +09:30
Rusty Russell
fc8552318a opt_bits: parsing routines for 'bits' == 100 satoshi.
Also fix open-channel usage message.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-07 13:52:04 +09:30
Rusty Russell
126192a842 create-steal-tx: get my money back!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:22:54 +09:30
Rusty Russell
904ef32459 bitcoin_tx: handle \n at end of file for tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
ca18eeeaa7 open-channel: fix revocation hash.
Revocation hash is SHA256 of output of generator.  Sometimes
that is the same as the next revocation hash (on even counts), but
not otherwise.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
6c62e20701 Note that we should check their locktime, minconfirms etc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
6048a15db9 bitcoin_tx: bitcoin_txid_from_hex helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
e1532ce044 bitcoin_script: get rid of scriptpubkey_pay_to_pubkeyhash.
We no longer generate any pay-to-pubkeys.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
d30c470c7d anchor: change is not an arbitrary output, but a pubkey we p2sh to.
Gets rid of the last pubkey user; they're generally deprecated.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 17:13:26 +09:30
Rusty Russell
29d0cdc3cd open-channel: use pubkey, not arbitrary script for final outout address.
We need to pay to this from two places: on their side, it's a simple
payment, on our side, it's a complex timeout-or-mutual-or-hval script,
which doesn't lend itself to arbitrary scripts.

Use P2SH, of course.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 11:37:27 +09:30
Rusty Russell
0742e5356f get-anchor-depth: simple helper to get min_confirms from OpenChannel packet
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 11:09:29 +09:30
Rusty Russell
33bbd38691 Makefile: cleanup and generalize
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 11:05:05 +09:30
Rusty Russell
a6b08dc393 protocol: add revocation hash to update_accept for other commit tx.
And clarify that we're going to be closing the anchor tx directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 11:04:04 +09:30
Rusty Russell
f7f7f3f1bb check-anchor-scriptsigs: don't require txs.
It's convenient to double-check that commit txs spend anchor, but it's
misleading since we wouldn't have access to the other side's tx, and
in practice we wouldn't even sign ours until we need it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-05 11:03:57 +09:30
Rusty Russell
8516798645 signature: fix signatures for p2sh inputs.
The subscript in this case is the redeemscript, not the input script.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 21:06:42 +09:30
Rusty Russell
cbad9a1fa5 bitcoin_script: remember to push extra 0 for OP_CHECKMULTISIG.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 21:04:50 +09:30
Rusty Russell
769d2fd722 bitcoin_script: fix out-by-one error in multisig.
Was using 3 instead of 2.  OP_LITERAL() was a bad idea anyway,
as it would only handle numbers up to 16 (and we use 32).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 16:20:36 +09:30
Rusty Russell
17c56a8cfc Fix DER encoding.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 15:46:49 +09:30
Rusty Russell
623c6562af Makefile: add TAGS target.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 15:46:39 +09:30
Rusty Russell
abac31072e open-anchor-scriptsig: use pubkey, not addr in scriptsig.
Oops.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 15:05:04 +09:30
Rusty Russell
50609c6771 open-channel: expect hex txids to be in LE (ie. reversed!) order.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 14:46:12 +09:30
Rusty Russell
3ed87c5e6f anchor: fix anchor production for RIPEMD hash.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 14:15:54 +09:30
Rusty Russell
617d21eb43 check-anchor-scriptsigs: dump out anchor tx if scriptsigs make expected tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 14:15:51 +09:30
Rusty Russell
a6d1c65683 Use new opt_usage_exit_fail().
opt_usage_and_exit() exits with status 0, and prints to stdout.
This exits status 1 and prints to stderr.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 14:15:19 +09:30
Rusty Russell
67f98fe6b6 Rename "anchor sig" to "anchor scriptsigs" to be clearer.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-04 12:10:01 +09:30
Rusty Russell
cf333e45e1 Fix thinko: open-commit-sig needs to sign *their* commit tx.
And check-commit-sig needs to check it against ours.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-03 13:58:23 +09:30
Rusty Russell
fe4972fda1 Anchor: apply permutation to get txid.
Otherwise both sides create different anchors.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 14:29:30 +09:30
Rusty Russell
c291d19af6 Add check-commit-sig.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 14:28:59 +09:30
Rusty Russell
316f29cb69 bitcoin_script: wean entirely off protobuf types.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 13:38:38 +09:30
Rusty Russell
f911b2b6df Use pubkey structures in bitcoin_script, rather than protobufs.
This ensures we do checking beforehand, and keeps abstractions clear.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 13:33:21 +09:30
Rusty Russell
bd38003db6 Add function to linearize tx into bytes, by generalizing hash code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 13:32:46 +09:30
Rusty Russell
393400fa39 Make an explicit bitcoin_txid() call.
Neater than open-coding it.  We still need the raw version for
signatures though.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 13:32:41 +09:30
Rusty Russell
07c7214edb Explicit pubkey structure.
This checks that the protobuf is the right form, also handles uncompressed
keys (though you shouldn't be using those any more, should you?)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-02 11:53:59 +09:30
Rusty Russell
7c977a7633 Move signature <-> proto conversions to signature.c, check lower bit.
Make sure signature can be used by bitcoin.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-01 14:24:18 +09:30
Rusty Russell
eec612af9f Use raw 64-byte signatures in protocol.
DER encoding introduces problems for non-canonical encodings; we should
do that only at the lightning<->bitcoin interface.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-06-01 13:04:00 +09:30
Rusty Russell
64b443dcd9 Add doubts on me & you sig on commit transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-05-30 21:05:55 +09:30
Rusty Russell
c04d20e019 commit_tx: new file containing logic to create initial commitment transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-05-30 20:44:00 +09:30