electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit fd7469745e56fa53307b48c35b59a77516051b93
parent 4d41299f1ca0af2852b95692ddf0b043042881e5
Author: SomberNight <somber.night@protonmail.com>
Date:   Mon, 23 Apr 2018 13:52:20 +0200

transaction.py: sign_txin. allow override for get_preimage_script.
test_commitment_tx_with_all_five_HTLCs_untrimmed_minimum_feerate now passes

Diffstat:
Mlib/lnbase.py | 13++++++-------
Mlib/tests/test_lnbase.py | 152+++++++++++++++++++++++++++++++++++++++++++++++--------------------------------
2 files changed, 96 insertions(+), 69 deletions(-)

diff --git a/lib/lnbase.py b/lib/lnbase.py @@ -358,27 +358,26 @@ def make_htlc_tx_witness(remotehtlcsig, localhtlcsig, payment_preimage, witness_ assert type(localhtlcsig) is bytes assert type(payment_preimage) is bytes assert type(witness_script) is bytes - return bfh(var_int(5) + '00' + ''.join([witness_push(x) for x in [bh2u(remotehtlcsig), bh2u(localhtlcsig), bh2u(payment_preimage), bh2u(witness_script)]])) + return bfh(var_int(5) + '00' + ''.join([witness_push(bh2u(x)) for x in [remotehtlcsig, localhtlcsig, payment_preimage, witness_script]])) -def make_htlc_tx_inputs(htlc_output_txid, htlc_output_index, revocationpubkey, local_delayedpubkey, amount_msat, witness, pubkeys, sigs): +def make_htlc_tx_inputs(htlc_output_txid, htlc_output_index, revocationpubkey, local_delayedpubkey, amount_msat, witness_script): assert type(htlc_output_txid) is str assert type(htlc_output_index) is int assert type(revocationpubkey) is bytes assert type(local_delayedpubkey) is bytes assert type(amount_msat) is int - assert type(witness) is bytes + assert type(witness_script) is str c_inputs = [{ 'scriptSig': '', 'type': 'p2wsh', - 'x_pubkeys': [bh2u(x) for x in pubkeys], - 'signatures': sigs, - 'num_sig': 2, + 'signatures': [], + 'num_sig': 0, 'prevout_n': htlc_output_index, 'prevout_hash': htlc_output_txid, 'value': amount_msat // 1000, 'coinbase': False, 'sequence': 0x0, - 'witness': bh2u(witness) + 'preimage_script': witness_script, }] return c_inputs diff --git a/lib/tests/test_lnbase.py b/lib/tests/test_lnbase.py @@ -102,39 +102,38 @@ class Test_LNBase(unittest.TestCase): remote_htlcpubkey = remotepubkey local_htlcpubkey = localpubkey + htlc2_cltv_timeout = 502 htlc2_payment_preimage = b"\x02" * 32 htlc2 = make_offered_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc2_payment_preimage) # HTLC 2 offered amount 2000 - # wscript ref_htlc2_wscript = "76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a914b43e1b38138a41b37f7cd9a1d274bc63e3a9b5d188ac6868" self.assertEqual(htlc2, bfh(ref_htlc2_wscript)) + htlc3_cltv_timeout = 503 htlc3_payment_preimage = b"\x03" * 32 htlc3 = make_offered_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc3_payment_preimage) # HTLC 3 offered amount 3000 - # wscript ref_htlc3_wscript = "76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a9148a486ff2e31d6158bf39e2608864d63fefd09d5b88ac6868" self.assertEqual(htlc3, bfh(ref_htlc3_wscript)) + htlc0_cltv_timeout = 500 htlc0_payment_preimage = b"\x00" * 32 - htlc0 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc0_payment_preimage, 500) + htlc0 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc0_payment_preimage, htlc0_cltv_timeout) # HTLC 0 received amount 1000 - # wscript ref_htlc0_wscript = "76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f401b175ac6868" self.assertEqual(htlc0, bfh(ref_htlc0_wscript)) - htlc1_cltv_expiry = 501 + htlc1_cltv_timeout = 501 htlc1_payment_preimage = b"\x01" * 32 - htlc1 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc1_payment_preimage, htlc1_cltv_expiry) + htlc1 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc1_payment_preimage, htlc1_cltv_timeout) # HTLC 1 received amount 2000 - # wscript ref_htlc1_wscript = "76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a9144b6b2e5444c2639cc0fb7bcea5afba3f3cdce23988527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f501b175ac6868" self.assertEqual(htlc1, bfh(ref_htlc1_wscript)) + htlc4_cltv_timeout = 504 htlc4_payment_preimage = b"\x04" * 32 - htlc4 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc4_payment_preimage, 504) + htlc4 = make_received_htlc(local_revocation_pubkey, remote_htlcpubkey, local_htlcpubkey, htlc4_payment_preimage, htlc4_cltv_timeout) # HTLC 4 received amount 4000 - # wscript ref_htlc4_wscript = "76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a91418bc1a114ccf9c052d3d23e28d3b0a9d1227434288527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f801b175ac6868" self.assertEqual(htlc4, bfh(ref_htlc4_wscript)) @@ -144,11 +143,11 @@ class Test_LNBase(unittest.TestCase): # local_signature = 30440220275b0c325a5e9355650dc30c0eccfbc7efb23987c24b556b9dfdd40effca18d202206caceb2c067836c51f296740c7ae807ffcbfbf1dd3a0d56b6de9a5b247985f06 output_commit_tx = "02000000000101bef67e4e2fb9ddeeb3461973cd4c62abb35050b1add772995b820b584a488489000000000038b02b8007e80300000000000022002052bfef0479d7b293c27e0f1eb294bea154c63a3294ef092c19af51409bce0e2ad007000000000000220020403d394747cae42e98ff01734ad5c08f82ba123d3d9a620abda88989651e2ab5d007000000000000220020748eba944fedc8827f6b06bc44678f93c0f9e6078b35c6331ed31e75f8ce0c2db80b000000000000220020c20b5d1f8584fd90443e7b7b720136174fa4b9333c261d04dbbd012635c0f419a00f0000000000002200208c48d15160397c9731df9bc3b236656efb6665fbfe92b4a6878e88a499f741c4c0c62d0000000000160014ccf1af2f2aabee14bb40fa3851ab2301de843110e0a06a00000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e04004730440220275b0c325a5e9355650dc30c0eccfbc7efb23987c24b556b9dfdd40effca18d202206caceb2c067836c51f296740c7ae807ffcbfbf1dd3a0d56b6de9a5b247985f060147304402204fd4928835db1ccdfc40f5c78ce9bd65249b16348df81f0c44328dcdefc97d630220194d3869c38bc732dd87d13d2958015e2fc16829e74cd4377f84d215c0b7060601475221023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb21030e9f7b623d2ccc7c9bd44d66d5ce21ce504c0acf6385a132cec6d3c39fa711c152ae3e195220" - htlc0_msat = 1000_000 - htlc2_msat = 2000_000 - htlc3_msat = 3000_000 - htlc1_msat = 2000_000 - htlc4_msat = 4000_000 + htlc0_msat = 1000 * 1000 + htlc2_msat = 2000 * 1000 + htlc3_msat = 3000 * 1000 + htlc1_msat = 2000 * 1000 + htlc4_msat = 4000 * 1000 htlcs = [(htlc2, htlc2_msat), (htlc3, htlc3_msat), (htlc0, htlc0_msat), (htlc1, htlc1_msat), (htlc4, htlc4_msat)] fee = local_feerate_per_kw * overall_weight(len(htlcs)) // 1000 @@ -158,7 +157,7 @@ class Test_LNBase(unittest.TestCase): commitment_number, local_funding_pubkey, remote_funding_pubkey, remotepubkey, local_payment_basepoint, remote_payment_basepoint, - local_revocation_pubkey, local_delayedpubkey, loccal_delay, + local_revocation_pubkey, local_delayedpubkey, local_delay, funding_tx_id, funding_output_index, funding_amount_satoshi, local_amount, remote_amount, local_dust_limit_satoshi, htlcs=htlcs) @@ -166,68 +165,97 @@ class Test_LNBase(unittest.TestCase): self.assertEqual(str(our_commit_tx), output_commit_tx) # (HTLC 0) - signature_for_output_0_remote_htlc = "304402206a6e59f18764a5bf8d4fa45eebc591566689441229c918b480fb2af8cc6a4aeb02205248f273be447684b33e3c8d1d85a8e0ca9fa0bae9ae33f0527ada9c162919a6" + signature_for_output_remote_htlc_0 = "304402206a6e59f18764a5bf8d4fa45eebc591566689441229c918b480fb2af8cc6a4aeb02205248f273be447684b33e3c8d1d85a8e0ca9fa0bae9ae33f0527ada9c162919a6" # (HTLC 2) - signature_for_output_1_remote_htlc = "3045022100d5275b3619953cb0c3b5aa577f04bc512380e60fa551762ce3d7a1bb7401cff9022037237ab0dac3fe100cde094e82e2bed9ba0ed1bb40154b48e56aa70f259e608b" + signature_for_output_remote_htlc_2 = "3045022100d5275b3619953cb0c3b5aa577f04bc512380e60fa551762ce3d7a1bb7401cff9022037237ab0dac3fe100cde094e82e2bed9ba0ed1bb40154b48e56aa70f259e608b" # (HTLC 1) - signature_for_output_2_remote_htlc = "304402201b63ec807771baf4fdff523c644080de17f1da478989308ad13a58b51db91d360220568939d38c9ce295adba15665fa68f51d967e8ed14a007b751540a80b325f202" + signature_for_output_remote_htlc_1 = "304402201b63ec807771baf4fdff523c644080de17f1da478989308ad13a58b51db91d360220568939d38c9ce295adba15665fa68f51d967e8ed14a007b751540a80b325f202" # (HTLC 3) - signature_for_output_3_remote_htlc = "3045022100daee1808f9861b6c3ecd14f7b707eca02dd6bdfc714ba2f33bc8cdba507bb182022026654bf8863af77d74f51f4e0b62d461a019561bb12acb120d3f7195d148a554" + signature_for_output_remote_htlc_3 = "3045022100daee1808f9861b6c3ecd14f7b707eca02dd6bdfc714ba2f33bc8cdba507bb182022026654bf8863af77d74f51f4e0b62d461a019561bb12acb120d3f7195d148a554" # (HTLC 4) - signature_for_output_4_remote_htlc = "304402207e0410e45454b0978a623f36a10626ef17b27d9ad44e2760f98cfa3efb37924f0220220bd8acd43ecaa916a80bd4f919c495a2c58982ce7c8625153f8596692a801d" + signature_for_output_remote_htlc_4 = "304402207e0410e45454b0978a623f36a10626ef17b27d9ad44e2760f98cfa3efb37924f0220220bd8acd43ecaa916a80bd4f919c495a2c58982ce7c8625153f8596692a801d" + + local_signature_htlc0 = "304402207cb324fa0de88f452ffa9389678127ebcf4cabe1dd848b8e076c1a1962bf34720220116ed922b12311bd602d67e60d2529917f21c5b82f25ff6506c0f87886b4dfd5" # derive ourselves output_htlc_success_tx_0 = "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219700000000000000000001e8030000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402206a6e59f18764a5bf8d4fa45eebc591566689441229c918b480fb2af8cc6a4aeb02205248f273be447684b33e3c8d1d85a8e0ca9fa0bae9ae33f0527ada9c162919a60147304402207cb324fa0de88f452ffa9389678127ebcf4cabe1dd848b8e076c1a1962bf34720220116ed922b12311bd602d67e60d2529917f21c5b82f25ff6506c0f87886b4dfd5012000000000000000000000000000000000000000000000000000000000000000008a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a914b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc688527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f401b175ac686800000000" - our_htlc0_tx_output = make_htlc_tx_output( - amount_msat=htlc0_msat, - local_feerate=local_feerate_per_kw, - revocationpubkey=local_revocation_pubkey, - local_delayedpubkey=local_delayedpubkey, - success=True) - - our_htlc0_tx_inputs = make_htlc_tx_inputs( - htlc_output_txid=our_commit_tx.txid(), - htlc_output_index=0, - revocationpubkey=local_revocation_pubkey, - local_delayedpubkey=local_delayedpubkey, - amount_msat=htlc0_msat, - witness=b"\x01\x04\xde\xad\xbe\xef", # deadbeef - pubkeys=[localpubkey, remotepubkey], - sigs=[None, signature_for_output_0_remote_htlc + "01"] - ) - - our_htlc0_tx = make_htlc_tx(0, - inputs=our_htlc0_tx_inputs, - output=our_htlc0_tx_output) - - our_htlc0_tx.sign({bh2u(localpubkey): (local_privkey[:-1], True)}) - #our_htlc0_tx.update_signatures(str(our_htlc0_tx)) - - self.assertEqual(our_htlc0_tx.inputs()[0]["signatures"], [local_signature_htlc0 + "01", signature_for_output_0_remote_htlc + "01"]) - - #self.sign_and_insert_remote_sig(our_htlc0_tx, remotepubkey, signature_for_output_0_remote_htlc, localpubkey, local_privkey) - - #our_htlc0_tx_witness = make_htlc_tx_witness( - # remotehtlcsig=bfh(signature_for_output_0_remote_htlc) + b"\x01", # 0x01 is SIGHASH_ALL - # localhtlcsig=bfh(local_signature_htlc0) + b"\x01", - # payment_preimage=htlc0_payment_preimage, - # witness_script=bfh(ref_htlc0_wscript) - # ) - - self.assertEqual(str(our_htlc0_tx), output_htlc_success_tx_0) - - # local_signature = 3045022100c89172099507ff50f4c925e6c5150e871fb6e83dd73ff9fbb72f6ce829a9633f02203a63821d9162e99f9be712a68f9e589483994feae2661e4546cd5b6cec007be5 + local_signature_htlc2 = "3045022100c89172099507ff50f4c925e6c5150e871fb6e83dd73ff9fbb72f6ce829a9633f02203a63821d9162e99f9be712a68f9e589483994feae2661e4546cd5b6cec007be5" output_htlc_timeout_tx_2 = "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219701000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100d5275b3619953cb0c3b5aa577f04bc512380e60fa551762ce3d7a1bb7401cff9022037237ab0dac3fe100cde094e82e2bed9ba0ed1bb40154b48e56aa70f259e608b01483045022100c89172099507ff50f4c925e6c5150e871fb6e83dd73ff9fbb72f6ce829a9633f02203a63821d9162e99f9be712a68f9e589483994feae2661e4546cd5b6cec007be501008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a914b43e1b38138a41b37f7cd9a1d274bc63e3a9b5d188ac6868f6010000" - # local_signature = 3045022100def389deab09cee69eaa1ec14d9428770e45bcbe9feb46468ecf481371165c2f022015d2e3c46600b2ebba8dcc899768874cc6851fd1ecb3fffd15db1cc3de7e10da + local_signature_htlc1 = "3045022100def389deab09cee69eaa1ec14d9428770e45bcbe9feb46468ecf481371165c2f022015d2e3c46600b2ebba8dcc899768874cc6851fd1ecb3fffd15db1cc3de7e10da" output_htlc_success_tx_1 = "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219702000000000000000001d0070000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402201b63ec807771baf4fdff523c644080de17f1da478989308ad13a58b51db91d360220568939d38c9ce295adba15665fa68f51d967e8ed14a007b751540a80b325f20201483045022100def389deab09cee69eaa1ec14d9428770e45bcbe9feb46468ecf481371165c2f022015d2e3c46600b2ebba8dcc899768874cc6851fd1ecb3fffd15db1cc3de7e10da012001010101010101010101010101010101010101010101010101010101010101018a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a9144b6b2e5444c2639cc0fb7bcea5afba3f3cdce23988527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f501b175ac686800000000" - # local_signature = 30440220643aacb19bbb72bd2b635bc3f7375481f5981bace78cdd8319b2988ffcc6704202203d27784ec8ad51ed3bd517a05525a5139bb0b755dd719e0054332d186ac08727 + local_signature_htlc3 = "30440220643aacb19bbb72bd2b635bc3f7375481f5981bace78cdd8319b2988ffcc6704202203d27784ec8ad51ed3bd517a05525a5139bb0b755dd719e0054332d186ac08727" output_htlc_timeout_tx_3 = "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219703000000000000000001b80b0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e0500483045022100daee1808f9861b6c3ecd14f7b707eca02dd6bdfc714ba2f33bc8cdba507bb182022026654bf8863af77d74f51f4e0b62d461a019561bb12acb120d3f7195d148a554014730440220643aacb19bbb72bd2b635bc3f7375481f5981bace78cdd8319b2988ffcc6704202203d27784ec8ad51ed3bd517a05525a5139bb0b755dd719e0054332d186ac0872701008576a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c820120876475527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae67a9148a486ff2e31d6158bf39e2608864d63fefd09d5b88ac6868f7010000" - # local_signature = 30440220549e80b4496803cbc4a1d09d46df50109f546d43fbbf86cd90b174b1484acd5402205f12a4f995cb9bded597eabfee195a285986aa6d93ae5bb72507ebc6a4e2349e + local_signature_htlc4 = "30440220549e80b4496803cbc4a1d09d46df50109f546d43fbbf86cd90b174b1484acd5402205f12a4f995cb9bded597eabfee195a285986aa6d93ae5bb72507ebc6a4e2349e" output_htlc_success_tx_4 = "020000000001018154ecccf11a5fb56c39654c4deb4d2296f83c69268280b94d021370c94e219704000000000000000001a00f0000000000002200204adb4e2f00643db396dd120d4e7dc17625f5f2c11a40d857accc862d6b7dd80e050047304402207e0410e45454b0978a623f36a10626ef17b27d9ad44e2760f98cfa3efb37924f0220220bd8acd43ecaa916a80bd4f919c495a2c58982ce7c8625153f8596692a801d014730440220549e80b4496803cbc4a1d09d46df50109f546d43fbbf86cd90b174b1484acd5402205f12a4f995cb9bded597eabfee195a285986aa6d93ae5bb72507ebc6a4e2349e012004040404040404040404040404040404040404040404040404040404040404048a76a91414011f7254d96b819c76986c277d115efce6f7b58763ac67210394854aa6eab5b2a8122cc726e9dded053a2184d88256816826d6231c068d4a5b7c8201208763a91418bc1a114ccf9c052d3d23e28d3b0a9d1227434288527c21030d417a46946384f88d5f3337267c5e579765875dc4daca813e21734b140639e752ae677502f801b175ac686800000000" + def test_htlc_tx(htlc, htlc_output_index, amount_msat, ref_local_sig, htlc_payment_preimage, remote_htlc_sig, ref_tx, success, cltv_timeout): + our_htlc_tx_output = make_htlc_tx_output( + amount_msat=amount_msat, + local_feerate=local_feerate_per_kw, + revocationpubkey=local_revocation_pubkey, + local_delayedpubkey=local_delayedpubkey, + success=success) + our_htlc_tx_inputs = make_htlc_tx_inputs( + htlc_output_txid=our_commit_tx.txid(), + htlc_output_index=htlc_output_index, + revocationpubkey=local_revocation_pubkey, + local_delayedpubkey=local_delayedpubkey, + amount_msat=amount_msat, + witness_script=bh2u(htlc)) + our_htlc_tx = make_htlc_tx(cltv_timeout, + inputs=our_htlc_tx_inputs, + output=our_htlc_tx_output) + + local_sig = our_htlc_tx.sign_txin(0, local_privkey[:-1]) + #self.assertEqual(ref_local_sig + "01", local_sig) # commented out as it is sufficient to compare the serialized txn + + our_htlc_tx_witness = make_htlc_tx_witness( # FIXME only correct for success=True + remotehtlcsig=bfh(remote_htlc_sig) + b"\x01", # 0x01 is SIGHASH_ALL + localhtlcsig=bfh(local_sig), + payment_preimage=htlc_payment_preimage if success else b'', # will put 00 on witness if timeout + witness_script=htlc) + our_htlc_tx._inputs[0]['witness'] = bh2u(our_htlc_tx_witness) + self.assertEqual(ref_tx, str(our_htlc_tx)) + + test_htlc_tx(htlc=htlc0, htlc_output_index=0, + amount_msat=htlc0_msat, + ref_local_sig=local_signature_htlc0, + htlc_payment_preimage=htlc0_payment_preimage, + remote_htlc_sig=signature_for_output_remote_htlc_0, + ref_tx=output_htlc_success_tx_0, + success=True, cltv_timeout=0) + test_htlc_tx(htlc=htlc1, htlc_output_index=2, + amount_msat=htlc1_msat, + ref_local_sig=local_signature_htlc1, + htlc_payment_preimage=htlc1_payment_preimage, + remote_htlc_sig=signature_for_output_remote_htlc_1, + ref_tx=output_htlc_success_tx_1, + success=True, cltv_timeout=0) + test_htlc_tx(htlc=htlc2, htlc_output_index=1, + amount_msat=htlc2_msat, + ref_local_sig=local_signature_htlc2, + htlc_payment_preimage=htlc2_payment_preimage, + remote_htlc_sig=signature_for_output_remote_htlc_2, + ref_tx=output_htlc_timeout_tx_2, + success=False, cltv_timeout=htlc2_cltv_timeout) + test_htlc_tx(htlc=htlc3, htlc_output_index=3, + amount_msat=htlc3_msat, + ref_local_sig=local_signature_htlc3, + htlc_payment_preimage=htlc3_payment_preimage, + remote_htlc_sig=signature_for_output_remote_htlc_3, + ref_tx=output_htlc_timeout_tx_3, + success=False, cltv_timeout=htlc3_cltv_timeout) + test_htlc_tx(htlc=htlc4, htlc_output_index=4, + amount_msat=htlc4_msat, + ref_local_sig=local_signature_htlc4, + htlc_payment_preimage=htlc4_payment_preimage, + remote_htlc_sig=signature_for_output_remote_htlc_4, + ref_tx=output_htlc_success_tx_4, + success=True, cltv_timeout=0) + def test_find_path_for_payment(self): p = Peer('', 0, 'a') p.on_channel_announcement({'node_id_1': 'b', 'node_id_2': 'c', 'short_channel_id': bfh('0000000000000001')})