Rusty Russell
602117e8bb
Add valgrind memcheck helpers.
Otherwise valgrind tells you when you test a hash; you want to
know if you hash uninitialized memory long before that.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
143e7e032c
Optimize revocable output a little.
Both paths do CHECKSIG, do that outside.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
733e655d17
getinput.sh: abstract out bitcoin-cli command.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
0666265b5e
HOWTO-USE.md: poor documentation for poor tools.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
98b1d478b1
test-cli: remove obsolete examples from program headers.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
d4a6fb8b2d
Add test script.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
924be8456e
create-commit-spend-tx: fix locktime, take into account updates.
We were using o2's locktime instead of o1's, and we didn't take
into account updates.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
a700a5cdca
create-commit-tx: allow creation of initial opening tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
fb036399eb
LICENSE: Make MIT licensing clear.
ccan/opt is GPLv2, so the test-cli utils are GPLv2, but they're temporary.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
c91d2b5206
ccan: add local copy.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
92ec2f874b
pkt: add pkt_totlen() helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
77387bb370
test-cli/create-commit-spend-tx: don't endian convert script_len.
That's done in mashalling and hashing code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
6389dbd455
protocol: restore locktime in blocks option.
This could be used by an always-on node to agressively shorten their timeouts.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
a0b621689e
TAGS: Improve support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
9f12b72476
Don't include mutual redemption in recovable commit tx output.
It's not clear it's needed, and without it there's a good reason to
delay dumping to the blockchain if a node becomes unreachable (since
you'll get your money faster if it comes back online).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
ef9463f6b1
Sort include lines (ignoring hacky cli test utils).
Put ccan first, openssl next, then standard headers, then locals.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
4e8eda47a1
Move hacky command line utils out to test-cli subdir.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
5776c7a9d8
Update .gitignore
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
442f321585
Move protobuf<->bitcoin converters out of bitcoin/
They're lightning-specific.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
612d713470
Move bitcoin stuff into bitcoin subdir.
It's not very interesting if you're looking for LN code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
28ea518182
create-steal-tx: use o1 to double-check final key is correct.
It's actually an unused parameter, but they symmetry with others in nice.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
2d714f5ad4
create-commit-tx: create a commit tx.
Required for unilateral close. Also lets us test stealing funds
from a revoked transaction.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
96585e1b00
create-steal-tx: fix it.
Couldn't be tested until we could generate updates; fixed now.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
975a5b2041
scriptsig_p2sh_2of2: fix sig order.
Must match key order, which we permute.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
ed3f0115d6
protocol: fix horribly thinko, keep own secrets.
I had each side using the other side's hash secret. That's a very
dumb idea, since it means you can steal from a unilateral close!
A's secret applies to A's commit transaction: it needs the
secret and B's final signature to steal funds, and that should
never happen (since A doesn't have the B's final signature, and
once A has given B the secret, they never broadcast the commit tx).
This makes the update a 4 step dance, since you need the new
revocation hash to make the other side's TX to sign.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
9caf2c71e8
close-channel / create-close-tx: take into account updates.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
a4517f27c7
Fix
10 years ago
Rusty Russell
3fef1584e5
update-channel-complete: final step in channel update.
(note: I didn't bother writing the code to check the sig on this).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
2bd967af35
update-channel-accept: check their signature is valid.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
3957f1e1c1
update-channel-accept: accept the channel update.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
d51f6372aa
update-channel: prepare a new tx with modified amounts.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
ecb39efed1
find_p2sh_out: extract helper.
Really only for our silly little utils.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
7175d73573
create-close-tx: create a mutual close tx from the close sigs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
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>
10 years ago
Rusty Russell
38f7a23064
close-channel: create message to mutually close channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
16baa1dae9
create-commit-spend-tx: spend the commit tx (after timeout)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
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>
10 years ago
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>
10 years ago
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>
10 years ago
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>
10 years ago
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>
10 years ago
Rusty Russell
baf5d11643
getinput.sh: Switch to -regtest
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
9ed6968fe5
add_varint: encode correctly (LE)
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
0203d51ec0
pull_varint: fix.
Adapted badly from pettycoin.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
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>
10 years ago
Rusty Russell
126192a842
create-steal-tx: get my money back!
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
904ef32459
bitcoin_tx: handle \n at end of file for tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
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>
10 years ago
Rusty Russell
6c62e20701
Note that we should check their locktime, minconfirms etc.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago
Rusty Russell
6048a15db9
bitcoin_tx: bitcoin_txid_from_hex helper.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
10 years ago