diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index b889d0e2b..f1c4f55fd 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -1699,6 +1699,8 @@ static void peer_got_shutdown(struct peer *peer, const u8 *msg) return; } + txfilter_add_scriptpubkey(peer->ld->owned_txfilter, scriptpubkey); + /* BOLT #2: * * A receiving node MUST reply to a `shutdown` message with a @@ -2688,6 +2690,8 @@ static void json_close(struct command *cmd, peer_set_condition(peer, CHANNELD_NORMAL, CHANNELD_SHUTTING_DOWN); + txfilter_add_scriptpubkey(peer->ld->owned_txfilter, shutdown_scriptpubkey); + if (peer->owner) subd_send_msg(peer->owner, take(towire_channel_send_shutdown(peer, diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index a8ffeaeca..3d2940a14 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -756,7 +756,7 @@ class LightningDTests(BaseLightningDTests): l1,l2 = self.connect() self.fund_channel(l1, l2, 10**6) - self.pay(l1,l2,200000000) + self.pay(l1, l2, 200000000) assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 0 @@ -771,8 +771,23 @@ class LightningDTests(BaseLightningDTests): # And should put closing into mempool. l1.daemon.wait_for_log('sendrawtx exit 0') l2.daemon.wait_for_log('sendrawtx exit 0') + assert l1.bitcoin.rpc.getmempoolinfo()['size'] == 1 + # Now grab the close transaction + closetxid = l1.bitcoin.rpc.getrawmempool(False)[0] + + l1.bitcoin.rpc.generate(10) + + l1.daemon.wait_for_log(r'Owning output .* txid %s' % closetxid) + l2.daemon.wait_for_log(r'Owning output .* txid %s' % closetxid) + + print(l1.rpc.listfunds()) + + # Make sure both nodes have grabbed their close tx funds + assert closetxid in set([o['txid'] for o in l1.rpc.listfunds()['outputs']]) + assert closetxid in set([o['txid'] for o in l2.rpc.listfunds()['outputs']]) + @unittest.skipIf(not DEVELOPER, "needs DEVELOPER=1") def test_permfail(self): l1,l2 = self.connect()