Rusty Russell
4957921e02
log: mark ltmp as notleak.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
c956d9f5eb
lightningd: tal memleak detection, dev-memleak command.
This is a primitive mark-and-sweep-style garbage detector. The core is
in common/ for later use by subdaemons, but for now it's just lightningd.
We initialize it before most other allocations.
We walk the tal tree to get all the pointers, then search the `ld`
object for those pointers, recursing down. Some specific helpers are
required for hashtables (which stash bits in the unused pointer bits,
so won't be found).
There's `notleak()` for annotating things that aren't leaks: things
like globals and timers, and other semi-transients.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
005f3826c9
wallet/tests: add mocks for futureproofing.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
Rusty Russell
2931760b5b
wallet: move tests into test/ dir like other unit tests.
Trivial move, but makes it easy to add new ones.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
7 years ago
practicalswift
486d321094
Avoid NULL pointer dereference in channelseq(...)
7 years ago
Christian Decker
f4a71f9806
tests: Add stmt2wallet test for remote_shutdown_scriptpubkey
We didn't test that this is done correctly. Now we are :-)
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Rusty Russell
b836b452dc
feerate: keep feerates separately for each side.
When we support changing them, they can be different during the transition.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
d1cc5f4552
wallet: Add unit tests for payment persistence
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Rusty Russell
f71a18241a
wallet: save and restore htlc_basepoint for remote side.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
4fb472b7a7
db: we must always be in a transaction, remove nested, call fatal()
We save location where transaction was started, in case we try to nest.
There's now no error case; db_exec_mayfail() is the only one.
This means the tests need to override fatal() if they want to intercept
these errors.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
7133a2f9b3
wallet: assume db errors will be fatal, don't check.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
3282768302
wallet: don't fail, assume db ops will call fatal.
And override fatal() in wallet_tests to be sure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
da183c22a0
db: Cleanup all remaining traces of hex-encoded values
In addition we also set some of the test values to a pattern instead
of just `memset`ting it to 0, which may hide some crossed lines.
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Rusty Russell
48cedef756
peer_control: remove unique_id field.
It's now completely useless.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
a005bce155
wallet: Adding primitives to save/load invoices to wallet
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
b4732f6091
wallet_tests: Testing the rewiring of loaded htlcs
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
e162a53e86
wallet_tests: Enable logging in the unit tests
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
eb5ed961ed
wallet: Added loading of HTLCs from the database
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
b8fa765c3f
wallet: Add primitives to store htlcs in the database
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
4bc0750882
wallet: Moving wallet_channel->peer_id into the peer struct
This was supposed to be a temporary solution anyway, and I had a
rather annoying mixup between peer_id and unique_id, the latter of
which is actually a connection identifier.
8 years ago
Rusty Russell
1ffb9f07c1
ccan: update to latest shachain.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
893335244d
openingd: supply initial tx as well as signature.
And store in peer->last_tx/peer->last_sig like all other places,
that way we broadcast it if we need to.
Note: the removal of tmpctx in funder_channel() is needed because we
use txs[0], which was allocated off tmpctx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
c389215a35
closingd: send the tx to master as we negotiate.
We can derive fees from this, and also broadcast at any time without
having to reconstruct it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Rusty Russell
dbfac68c3f
lightningd: keep last valid tx, and its signature.
This avoids us having to reconstruct it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
8 years ago
Christian Decker
1ac10716be
wallet: Add closing parameters to channel state
I must have missed these before, so adding them now.
8 years ago
Christian Decker
1070bbccde
wallet: Add channel_config persistence to channel persistence
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
f2382884b6
wallet: Add roundtrip test for channel_config persistence
Signed-off-by: Christian Decker <decker.christian@gmail.com>
8 years ago
Christian Decker
6f441d3cd2
wallet: Add a CRU(D) test for wallet_channels
Simple roundtrip testing which writes to DB, reads it back in and
checks for equality.
8 years ago
Christian Decker
8b7efd01d7
wallet: Created a simple persisted shachain unit-test
This exercises the create, read and update functionality of the
persisted shachain.
8 years ago
Christian Decker
bdb6b1002f
wallet: Reserve UTXOs used in build_utxos
8 years ago
Christian Decker
5396335363
wallet: Add wallet_tests and simplify db_tests
I'll eventually move the utils into a different location (maybe CCAN?)
but for now I'm keeping it close to where it is used.
8 years ago