def test_send_p2wpkh_in_p2sh(self): coin = coins.by_name('Groestlcoin Testnet') seed = bip39.seed(' '.join(['all'] * 12), '') inp1 = TxInputType( # 49'/1'/0'/1/0" - 2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7 address_n=[49 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 0], amount=123456789, prev_hash=unhexlify( '09a48bce2f9d5c6e4f0cb9ea1b32d0891855e8acfe5334f9ebd72b9ad2de60cf' ), prev_index=0, script_type=InputScriptType.SPENDP2SHWITNESS, sequence=0xfffffffe, multisig=None, ) out1 = TxOutputType( address='mvbu1Gdy8SUjTenqerxUaZyYjmvedc787y', amount=12300000, script_type=OutputScriptType.PAYTOADDRESS, address_n=[], multisig=None, ) out2 = TxOutputType( address='2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7', script_type=OutputScriptType.PAYTOADDRESS, amount=123456789 - 11000 - 12300000, address_n=[], multisig=None, ) tx = SignTx(coin_name='Groestlcoin Testnet', version=None, lock_time=650756, inputs_count=1, outputs_count=2) messages = [ None, # check fee TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(outputs=[out1])), helpers.UiConfirmOutput(out1, coin), True, TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(outputs=[out2])), helpers.UiConfirmOutput(out2, coin), True, helpers.UiConfirmNonDefaultLocktime(tx.lock_time), True, helpers.UiConfirmTotal(123445789 + 11000, 11000, coin), True, # sign tx TxRequest( request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized header serialized_tx=unhexlify('01000000000101'), )), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest( request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized inp1 serialized_tx=unhexlify( 'cf60ded29a2bd7ebf93453feace8551889d0321beab90c4f6e5c9d2fce8ba4090000000017160014d16b8c0680c61fc6ed2e407455715055e41052f5feffffff02' ), )), TxAck(tx=TransactionType(outputs=[out1])), TxRequest( request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out1 serialized_tx=unhexlify( 'e0aebb00000000001976a914a579388225827d9f2fe9014add644487808c695d88ac' ), signature_index=None, signature=None, )), TxAck(tx=TransactionType(outputs=[out2])), # segwit TxRequest( request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out2 serialized_tx=unhexlify( '3df39f060000000017a91458b53ea7f832e8f096e896b8713a8c6df0e892ca87' ), signature_index=None, signature=None, )), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest( request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType( serialized_tx=unhexlify( '02483045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80012103e7bfe10708f715e8538c92d46ca50db6f657bbc455b7494e6a0303ccdb868b7904ee0900' ), signature_index=0, signature=unhexlify( '3045022100b7ce2972bcbc3a661fe320ba901e680913b2753fcb47055c9c6ba632fc4acf81022001c3cfd6c2fe92eb60f5176ce0f43707114dd7223da19c56f2df89c13c2fef80' ), )), ] ns = get_namespaces_for_coin(coin) keychain = Keychain(seed, ns) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) with self.assertRaises(StopIteration): signer.send(None)
def test_send_native_p2wpkh(self): coin = coins.by_name('Groestlcoin Testnet') seed = bip39.seed(' '.join(['all'] * 12), '') inp1 = TxInputType( # 84'/1'/0'/0/0" - tgrs1qkvwu9g3k2pdxewfqr7syz89r3gj557l3ued7ja address_n=[84 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 0, 0], amount=12300000, prev_hash=unhexlify( '4f2f857f39ed1afe05542d058fb0be865a387446e32fc876d086203f483f61d1' ), prev_index=0, script_type=InputScriptType.SPENDWITNESS, sequence=0xfffffffe, multisig=None, ) out1 = TxOutputType( address='2N4Q5FhU2497BryFfUgbqkAJE87aKDv3V3e', amount=5000000, script_type=OutputScriptType.PAYTOADDRESS, address_n=[], multisig=None, ) out2 = TxOutputType( address='tgrs1qejqxwzfld7zr6mf7ygqy5s5se5xq7vmt9lkd57', script_type=OutputScriptType.PAYTOADDRESS, amount=12300000 - 11000 - 5000000, address_n=[], multisig=None, ) tx = SignTx(coin_name='Groestlcoin Testnet', version=None, lock_time=650713, inputs_count=1, outputs_count=2) messages = [ None, # check fee TxRequest(request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(outputs=[out1])), helpers.UiConfirmOutput(out1, coin), True, TxRequest(request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=EMPTY_SERIALIZED), TxAck(tx=TransactionType(outputs=[out2])), helpers.UiConfirmOutput(out2, coin), True, helpers.UiConfirmNonDefaultLocktime(tx.lock_time), True, helpers.UiConfirmTotal(12300000, 11000, coin), True, # sign tx TxRequest( request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized header serialized_tx=unhexlify('01000000000101'), )), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest( request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized inp1 serialized_tx=unhexlify( 'd1613f483f2086d076c82fe34674385a86beb08f052d5405fe1aed397f852f4f0000000000feffffff02' ), )), TxAck(tx=TransactionType(outputs=[out1])), TxRequest( request_type=TXOUTPUT, details=TxRequestDetailsType(request_index=1, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out1 serialized_tx=unhexlify( '404b4c000000000017a9147a55d61848e77ca266e79a39bfc85c580a6426c987' ), signature_index=None, signature=None, )), TxAck(tx=TransactionType(outputs=[out2])), # segwit TxRequest( request_type=TXINPUT, details=TxRequestDetailsType(request_index=0, tx_hash=None), serialized=TxRequestSerializedType( # returned serialized out2 serialized_tx=unhexlify( 'a8386f0000000000160014cc8067093f6f843d6d3e22004a4290cd0c0f336b' ), signature_index=None, signature=None, )), TxAck(tx=TransactionType(inputs=[inp1])), TxRequest( request_type=TXFINISHED, details=TxRequestDetailsType(), serialized=TxRequestSerializedType( serialized_tx=unhexlify( '02483045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f862d9ed0900' ), signature_index=0, signature=unhexlify( '3045022100ea8780bc1e60e14e945a80654a41748bbf1aa7d6f2e40a88d91dfc2de1f34bd10220181a474a3420444bd188501d8d270736e1e9fe379da9970de992ff445b0972e3' ), )), ] keychain = Keychain(seed, [[coin.curve_name]]) signer = bitcoinlike.Bitcoinlike(tx, keychain, coin).signer() for request, response in chunks(messages, 2): self.assertEqual(signer.send(request), response) with self.assertRaises(StopIteration): signer.send(None)