From 6d0fd84c63775e02f7bb73f6d8f72a36d295b469 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 29 Jan 2018 16:29:21 +1030 Subject: [PATCH] walletrpc: don't assert() when we pay ourselves. Signed-off-by: Rusty Russell --- tests/test_lightningd.py | 7 +++++++ wallet/walletrpc.c | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 178fdad2e..b900d9823 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -2427,6 +2427,13 @@ class LightningDTests(BaseLightningDTests): c.execute('SELECT COUNT(*) FROM outputs WHERE status=0') assert(c.fetchone()[0] == 6) + # Test withdrawal to self. + out = l1.rpc.withdraw(l1.rpc.newaddr()['address'], 'all') + bitcoind.rpc.generate(1) + c = db.cursor() + c.execute('SELECT COUNT(*) FROM outputs WHERE status=0') + assert(c.fetchone()[0] == 1) + out = l1.rpc.withdraw(waddr, 'all') c = db.cursor() c.execute('SELECT COUNT(*) FROM outputs WHERE status=0') diff --git a/wallet/walletrpc.c b/wallet/walletrpc.c index 140db166a..4a3fe76b7 100644 --- a/wallet/walletrpc.c +++ b/wallet/walletrpc.c @@ -58,7 +58,9 @@ static void wallet_withdrawal_broadcast(struct bitcoind *bitcoind, tx = bitcoin_tx_from_hex(withdraw, withdraw->hextx, strlen(withdraw->hextx)); assert(tx != NULL); wallet_extract_owned_outputs(ld->wallet, tx, &change_satoshi); - assert(change_satoshi == withdraw->changesatoshi); + + /* Note normally, change_satoshi == withdraw->changesatoshi, but + * not if we're actually making a payment to ourselves! */ struct json_result *response = new_json_result(cmd); json_object_start(response, NULL);