示例#1
0
    def test_send_to_bech32(self):
        # Generated with regtest
        pk = PrivateKey.from_wif(
            "cVC6z7gnezHZut5yyuCX3x79tfcbauCWiFcBY92Vg4crfu4Maa5B")

        utxo = Utxo(
            "658d10f95cfcee9674e13cdb29007d407ea8c7d2ec6ae5502a3a9aae74890b27",
            0, "miVjzzA21B96xva2aCcaUb8h4RFbf6qKBZ", 25, pk)

        spender = B2XSpender()
        spender.add_utxos(utxo)
        # cSYZYCLT1t9WnAQwTNzfPdg3RXySxu1ewVmRZPXsGkdgUnM2T3uL
        spender.add_destinations(
            Destination(24.9, "tb1qv3ya29z8nddpxkq4dzllzl0ceujacqvw3hjhh9"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000001270b8974ae9a3a2a50e56aecd2c7a87e407d0029db3ce17496eefc5cf9108d65000000006b48304502"
            "2100863d673a5932ff107ece66d97c813701f85c228da0ccf6937caaf18b7c765b7802207c7ee2917c5d65874907"
            "fa14fefcf6f97de4af1f79fdea4c9182afc860fb519d3121030f96812693c4a50162134cfa307afb63580171963d"
            "6c4198e8e5cfeee2c92b60ffffffff0180626a94000000001600146449d514479b5a13581568bff17df8cf25dc01"
            "8e00000000")

        self.assertEqual(expected, tx_hex)
示例#2
0
    def test_send_to_bech32(self):
        pk = PrivateKey.from_wif(
            "cQzqkdWwGaRfY7KK5jLt6uEvTxWDZXXhRUcdY9Eaz6Geq81685BX")

        utxo = Utxo(
            "243e1aa0b5cb8134a91f63a09523831bd1245683549a574f1b5c997fb89d1ebf",
            0, "n2njoVpqeoCupZhqt8myDnWaLFzirbgHtQ", 9.96000001, pk)

        spender = BPASpender()
        spender.add_utxos(utxo)

        spender.add_destinations(
            Destination(9.95000001,
                        "tb1qra8njpfw75hcu4s6ad687xrtemddzjrz5pfjsy"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000001bf1e9db87f995c1b4f579a54835624d11b832395a0631fa93481cbb5a01a3e24000000006"
            "a47304402201ca4637fdd04626457ec528878b902220e29af6ca6696ce36b5d904f9dcbe1ec02205466"
            "224c1817f09244de7aaf7a12b3c5f0e8736ce840fc415e89196cacd92b4421210331a2c9442b1c0cbd0"
            "c1d5a291bc863cf11ebbc26537f1602d1d0a6a30d5725cbffffffff01c17e4e3b000000001600141f4f"
            "39052ef52f8e561aeb747f186bcedad1486200000000")

        self.assertEqual(expected, tx_hex)
示例#3
0
    def test_spend_multiple_inputs(self):
        pk = PrivateKey.from_wif(
            "91r82bjCYhYnimoCoqySeNk9AMaHFgPEedzXSCwb39vHiZLSBCQ")

        utxo1 = Utxo(
            "24b0d378e09fb5f726f2c2e5373463276e1c9e9aed4e5907ae139741ec722e2f",
            0, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4", 0.99994220, pk)
        utxo2 = Utxo(
            "beb74ea7c6cc3a8875acaeb23f117d4b9408d8d684355b27e605ab38c1edf854",
            0, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4", 0.21594873, pk)
        utxo3 = Utxo(
            "8df2ad0242b7634fe082c5b2e92c41d550c6cf0b5083f944677a42c69f90bc3d",
            0, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4", 0.09979705, pk)
        utxo4 = Utxo(
            "7a763bc6ea8f790766835459d7f0735c6952bfe9a5ed3220f12f536a7ff59743",
            0, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4", 0.06530584, pk)

        spender = Spender()
        spender.add_utxos(utxo1)
        spender.add_utxos(utxo2)
        spender.add_utxos(utxo3)
        spender.add_utxos(utxo4)
        spender.add_destinations(
            Destination(1.38, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "02000000042f2e72ec419713ae07594eed9a9e1c6e27633437e5c2f226f7b59fe078d3b02400000000"
            "8b483045022100884d06e7b7515afb20062b2e855a224357a8731aba085eee2910e7416a15ca9f0220"
            "63969980c89cd112d23d09abed52db857a00dc634e0106b5eec01c4ea67d85f5014104dc406568adad"
            "d693f302205af9694bf3caf3da0374f2183bea4680fb0d1f5cf5f06c2a78a0229129023260658e4e9f"
            "37d7d9e22fad81dfdbb944163138a82b68ffffffff54f8edc138ab05e6275b3584d6d808944b7d113f"
            "b2aeac75883accc6a74eb7be000000008b483045022100daf2b144c38ca30eb74aa62aed2814833260"
            "e7e4ab1edfe4fa97311b7ba6228402207699e6287073bf41e8f9113efa5b697004d8978c1939b57569"
            "186d4dfcefb9c4014104dc406568adadd693f302205af9694bf3caf3da0374f2183bea4680fb0d1f5c"
            "f5f06c2a78a0229129023260658e4e9f37d7d9e22fad81dfdbb944163138a82b68ffffffff3dbc909f"
            "c6427a6744f983500bcfc650d5412ce9b2c582e04f63b74202adf28d000000008b483045022100d75d"
            "de09a577a3d481fc2757490ccc8f65fd81a380e039475fb39114b1a34dff0220776d31bcc3f81adb23"
            "93762494c2424195fcb1ca06bc7595ba352dec69deffbf014104dc406568adadd693f302205af9694b"
            "f3caf3da0374f2183bea4680fb0d1f5cf5f06c2a78a0229129023260658e4e9f37d7d9e22fad81dfdb"
            "b944163138a82b68ffffffff4397f57f6a532ff12032eda5e9bf52695c73f0d75954836607798feac6"
            "3b767a000000008a47304402204d19e36764310b0e70c51f19ff1db582c0b15f7ed36c408119137250"
            "efec81ee02206851c6247c031407a37c60a920a9f1f03a2bac2ce49a97f76a626fa57c2b6937014104"
            "dc406568adadd693f302205af9694bf3caf3da0374f2183bea4680fb0d1f5cf5f06c2a78a022912902"
            "3260658e4e9f37d7d9e22fad81dfdbb944163138a82b68ffffffff0180b63908000000001976a914f1"
            "3bdea27f1fdfb164d083dd827ff55eb140d68688ac00000000")

        self.assertEqual(expected, tx_hex)
示例#4
0
    def test_spend_p2pkh(self):
        pk = PrivateKey.from_wif("cUio9ok9CXDfByfGEiRi8snZmwSaAbnvdbmfg72wegPdkX4b7Cq5")

        utxo = Utxo("c9338d3cb5ce17fcfaee8ccadd7513110aee3148fbce1bc978d245d180fd7ad8", 1,
                    "msDmp5xD5hNLsiyasWjNpuxPuz1BfY2G9R", 10, pk)

        spender = BTVSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(Destination(9.960, "msDmp5xD5hNLsiyasWjNpuxPuz1BfY2G9R"))

        tx_hex = spender.create_tx().hex()

        expected = ("0200000001d87afd80d145d278c91bcefb4831ee0a111375ddca8ceefafc17ceb53c8d33c9010000006a4730440220"
                    "1d751f140d560c127ab6f3583dd9052c7556cd9457baa59c4087350840182f9b0220296cdbabb280591ef013a15e97"
                    "5c93e2cedb8c6fa30f9eed359a2bb125847562412103e9745d6b951c47251c63e7677985c2e8f90a85073c9a946148"
                    "5f7711f3a66707ffffffff0100c15d3b000000001976a9148061b01d9ad56cbe943fe4b55ab4629136a3596e88ac00"
                    "000000")

        self.assertEqual(expected, tx_hex)
示例#5
0
    def test_spend_p2wpkh(self):
        pk = PrivateKey.from_wif("cSYZYCLT1t9WnAQwTNzfPdg3RXySxu1ewVmRZPXsGkdgUnM2T3uL")

        utxo = Utxo("824799a7d3e9cc4227bc36e0bb6d11d750a87b4483f6454c4804ad2222581b8f", 0,
                    "tb1qv3ya29z8nddpxkq4dzllzl0ceujacqvw3hjhh9", 9.90, pk)

        spender = BTVSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(Destination(9.89998999, "msDmp5xD5hNLsiyasWjNpuxPuz1BfY2G9R"))

        tx_hex = spender.create_tx().hex()

        expected = ("020000000001018f1b582222ad04484c45f683447ba850d7116dbbe036bc2742cce9d3a79947820000000"
                    "000ffffffff01972f023b000000001976a9148061b01d9ad56cbe943fe4b55ab4629136a3596e88ac0248"
                    "3045022100b791b0e3119daded4d133ed9f256d524cc6ede34149b6e469a14ab15ce01eba002206d28172"
                    "369cfcf8a5aa04e441df337a73888f019726d55a791033a47e0ae550f412102aa81267011ee208bef8843"
                    "ceb883e45f4ab13f5dc2f4e17b7781d6245bab292600000000")

        self.assertEqual(expected, tx_hex)
示例#6
0
    def test_send_to_bech32(self):
        pk = PrivateKey.from_wif("cUio9ok9CXDfByfGEiRi8snZmwSaAbnvdbmfg72wegPdkX4b7Cq5")

        utxo = Utxo("b7b3b915e7b90f57426e18aeb4f5d42a1189902122a11278c432b0b74cf7cede", 0,
                    "msDmp5xD5hNLsiyasWjNpuxPuz1BfY2G9R", 9.96, pk)

        spender = BTVSpender()
        spender.add_utxos(utxo)
        # cSYZYCLT1t9WnAQwTNzfPdg3RXySxu1ewVmRZPXsGkdgUnM2T3uL
        spender.add_destinations(Destination(9.9, "tb1qv3ya29z8nddpxkq4dzllzl0ceujacqvw3hjhh9"))

        tx_hex = spender.create_tx().hex()

        expected = ("0200000001decef74cb7b032c47812a122219089112ad4f5b4ae186e42570fb9e715b9b3b700000000"
                    "6a47304402204e8d98dc8038641ed72712b939a885d4c70b9d30360311a86bd0273f2ae9b116022030"
                    "d73e717711a7f6d9488557bab272e64d3c4a0618c4e5259ad593d316ad6415412103e9745d6b951c47"
                    "251c63e7677985c2e8f90a85073c9a9461485f7711f3a66707ffffffff018033023b00000000160014"
                    "6449d514479b5a13581568bff17df8cf25dc018e00000000")

        self.assertEqual(expected, tx_hex)
示例#7
0
    def test_spend_p2pkh(self):
        pk = PrivateKey.from_wif(
            "cU4TK4AU8zCSVAwPkBdgreQauTnMSERoiFpvd1MJtyavD27fpYL2")

        utxo = Utxo(
            "dc719183637718c2958bfa565d93416824a4ee55e5524521dbad672bfbd88947",
            1, "mgWwTDdpMawWS7aeTmZ3qmDwECvHtbZyBf", 8, pk)

        spender = BTNSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(7.99, "mptcoGaQcovBDqJEXyf8XRUdTGYPCfFxq1"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "02000000014789d8fb2b67addb214552e555eea4246841935d56fa8b95c2187763839171dc01000000"
            "6a47304402206b4a9264a2617d9aa1c280832240ae2180e6e5ab83afefc3a9116ca9ebcd9006022078"
            "c72fe4ed38f562014a088280fb218cef43203689c84a0bf7dd0c708855575f412103db27f9d7a206f7"
            "7fd904c779709b1589844c1d3afb2b2a223eb106ca9481430cffffffff01c0c59f2f000000001976a9"
            "1466d2022f2ef98cc32f8c58d198b9fe1b82a6665588ac00000000")
        self.assertEqual(expected, tx_hex)
示例#8
0
    def test_spend_p2wpkh(self):
        pk = PrivateKey.from_wif(
            "KzGv8HkggHyio1vGGF1Z7sQERvknpMKg82qr4uhmkJn4PBDefyRv")

        utxo = Utxo(
            "a53044b74dd42a45aae1f693949423f33c9f0be0941475cceb02579bdd76ca92",
            0, "tb1qvnwx4vgelj3dlnp7s7uahaa45ck3esvh32eh80", 9.993, pk)

        spender = BCISpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(9.98, "ms8T2Mki2Cy4AkYZynnVVoXKnt4R87pXK3"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000000010192ca76dd9b5702ebcc751494e00b9f3cf323949493f6e1aa452ad44db74430a5000"
            "0000000ffffffff0180457c3b000000001976a9147f5feca396a2e8cbf290753af7d47a6493ff46b4"
            "88ac0247304402204c195e4e9bcac037db01cc65231d750a8f887185152f2dbb1ef750c786fdf75f0"
            "22043a4abf181e3f6a6a01fc7ff3799a74adeedbfb0967a90e8fa9c90581f36ce3e412102e959fb1b"
            "bb68cb44ed91739befc1dd93f47998b8d74eb34ff0e71da4c921e42a00000000")

        self.assertEqual(expected, tx_hex)
示例#9
0
    def test_spend_p2wpkh(self):
        pk = PrivateKey.from_wif(
            "L1yDt2VzCMQHoHwbtwwXgvgR3eTSTrnX681rZo1ZP77mWYBXLz1R")

        utxo = Utxo(
            "6be023686146f09cd04a2c00183fad462dd6695cf174e4d42ab9024a57055351",
            0, "tb1qra8njpfw75hcu4s6ad687xrtemddzjrz5pfjsy", 9.95000001, pk)

        spender = BPASpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(9.94, "mpLNpwccBEZxv729ds8ne2eE7h1Twqmq6q"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "02000000000101515305574a02b92ad4e474f15c69d62d46ad3f18002c4ad09cf046616823e06b000000"
            "0000ffffffff01803c3f3b000000001976a91460b909046298988c59767c0343dd424ebf79ba6c88ac02"
            "483045022100dced32a6e20d2bdab81e9ac6e0912b92c1633f70368eb5c04408049d8668188e0220468b"
            "df80a6f3706758820f9d825735c2222496d0e584d52ac8ce2f761630408e2121023130497ba9dda8f3f2"
            "9ee662500e1ff5b5d135169a57210c055bff78e75d347300000000")

        self.assertEqual(expected, tx_hex)
示例#10
0
    def test_spend_p2pkh(self):
        pk = PrivateKey.from_wif(
            "cQzxzNwiXTds7Aa26xX2po8H6iVMo4R7ZbvW3sohkchNnkXir3cz")

        utxo = Utxo(
            "a550c89a0a8711dad2998614be0d05d237cb6deaf92edbbbc62884d479cd9721",
            0, "mzTfa7VEwjpuYYDkqxEFDwurDifruWWVaN", 9.98, pk)

        spender = BPASpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(9.96000001, "n2njoVpqeoCupZhqt8myDnWaLFzirbgHtQ"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "02000000012197cd79d48428c6bbdb2ef9ea6dcb37d2050dbe148699d2da11870a9ac850a500000000"
            "6b483045022100d75d05c1813d5b4ff0951b05b54a1419a80583a4f21731d0ed2989ef7c8235ce0220"
            "5676dca70070f7982a3fc4dc1ecffd924efb59be7971781c227faaa1090e732b212102f2d6f4327cd0"
            "870c1fd15effc3bf56acdc5a0d0e5b9c0fb11815e8e5b613b822ffffffff0101c15d3b000000001976"
            "a914e956de67151c4c604861aa3d3ea05a2628a0ac0888ac00000000")

        self.assertEqual(expected, tx_hex)
示例#11
0
    def test_spend_p2pkh(self):
        # Generated with regtest
        pk = PrivateKey.from_wif(
            "cVC6z7gnezHZut5yyuCX3x79tfcbauCWiFcBY92Vg4crfu4Maa5B")

        utxo = Utxo(
            "b6d073333c1a8e4360b1e2c7fa2ed6b67b74272ad7fabf52a4e4732df5f47dbd",
            0, "miVjzzA21B96xva2aCcaUb8h4RFbf6qKBZ", 50, pk)

        spender = B2XSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(49.960, "mrVqpGm7F5MVCwsP4s3fQEN2GAaykJoTu4"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000001bd7df4f52d73e4a452bffad72a27747bb6d62efac7e2b160438e1a3c3373d0b6000000006a473044022"
            "01df7c8c97443bd46da751e0051a4395ba3613be3604be97d3c801c21e3d23c79022012ad30b7ffd42ad7bb96f915"
            "7519f7e3c35409ed54f783a3c854a596343a6c713121030f96812693c4a50162134cfa307afb63580171963d6c419"
            "8e8e5cfeee2c92b60ffffffff0100e9c829010000001976a91478738f2c5a75397eb2f851597261f766a67d9b6388"
            "ac00000000")

        self.assertEqual(expected, tx_hex)
示例#12
0
    def test_spend_p2wpkh(self):
        # Generated with regtest with cmd line ./bitcoin2x-qt -regtest -prematurewitness
        pk = PrivateKey.from_wif(
            "cSYZYCLT1t9WnAQwTNzfPdg3RXySxu1ewVmRZPXsGkdgUnM2T3uL")

        utxo = Utxo(
            "207d7cfb444c26a22bb7fb9eee72ff9bc0abc09d571254b3192024320215954c",
            0, "tb1qv3ya29z8nddpxkq4dzllzl0ceujacqvw3hjhh9", 24.9, pk)

        spender = B2XSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(24.8, "mxoVHNnvAEGYCFdPRR8yJw1yuuZfzkr2e7"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "020000000001014c95150232242019b35412579dc0abc09bff72ee9efbb72ba2264c44fb7c7d200000000000fffff"
            "fff0100ccd193000000001976a914bd9aa9556109944bb1d984286eec13199c723deb88ac02473044022026892552"
            "385d049b847e15c8436fc1053fc4c50f376f9dcf7520cbfc2d6ed8cf022078d323b34aa09845c8d362007c2bf7204"
            "463cc4911b27f0e1814aa51181f5db4312102aa81267011ee208bef8843ceb883e45f4ab13f5dc2f4e17b7781d624"
            "5bab292600000000")

        self.assertEqual(expected, tx_hex)
示例#13
0
    def test_send_to_bech32(self):
        pk = PrivateKey.from_wif(
            "cR735DHmZMw1KGAoLaKeCNYTY1iBQ2hwYs73xGTSMGrpXKG8y2bV")

        utxo = Utxo(
            "2ab1ad93934c2c02060a42cf71e9a37556929679dc78e9d18ec0d01951e2bc62",
            0, "mptcoGaQcovBDqJEXyf8XRUdTGYPCfFxq1", 7.99, pk)

        spender = BTNSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(7.98, "tb1quhs3fvy00aq80zcgvtdd9rrt835ecch4ay5ys2"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "020000000162bce25119d0c08ed1e978dc7996925675a3e971cf420a06022c4c9393adb12a"
            "000000006a47304402206a71dcec6f1f8850e930372de047164b2a4a4bb6e6ec47af134ae5"
            "0b0997537902202f22db1c2b77a9458bdd2783c9c691bf654c0066acb3c5832000c7bb2f86"
            "7a6a412103885eee783dfc7892f354544796be139324f637c8da33655b53852fcbf3d6d65d"
            "ffffffff018083902f00000000160014e5e114b08f7f40778b0862dad28c6b3c699c62f500"
            "000000")

        self.assertEqual(expected, tx_hex)
示例#14
0
    def test_spend_p2pkh(self):
        pk = PrivateKey.from_wif(
            "cRE4ietJxmEyum3SHny9quVLTY9k7XZ9tKvqyctVMHaYA7zhfrJE")

        utxo = Utxo(
            "eeae2d76ed671015f47f8103533aeed4ef0b0557156657b5b2774a44c7780abe",
            0, "mzw8EynNdyR2jzE8cXktpiTU7oGs1MURdA", 10, pk)

        spender = BCISpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(9.9999, "mh77F22aAnE4uF6CourTRpRCRLCUPTUVo2"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000001be0a78c7444a77b2b557661557050befd4ee3a5303817ff4151067ed762"
            "daeee000000006b483045022100faef70293f42675ef9ca6df584c3e83a156ea30346"
            "59ea8abeb033e589cbe69a02204fc86dabbac7ddbe5d6f10d6199d1133bab07d1cfad"
            "33ccb69aa1bbcc21020fd412102f2fcf143b17f6763a4e633a6565f4d56711e1eede6"
            "41473027db2eb07227f241ffffffff01f0a29a3b000000001976a914116dbcd48cf8b"
            "3d0498852b1e4bc0a6ab17d9b4688ac00000000")

        self.assertEqual(expected, tx_hex)
示例#15
0
    def test_spend_p2wpkh(self):
        pk = PrivateKey.from_wif(
            "cS8ycBgjYBuNgeBacXRbvbAtbqoki13yUond8NKnipyFzyMrJc6m")

        utxo = Utxo(
            "f46bd6e93fdd51876c2d7639cfd705b82c60b8301f2a8479b80585ed9b246826",
            0, "tb1quhs3fvy00aq80zcgvtdd9rrt835ecch4ay5ys2", 7.98, pk)

        spender = BTNSpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(7.97, "mqmXo6XKQYgPHVS4zFS6MApdpXcMs47vda"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "020000000001012668249bed8505b879842a1f30b8602cb805d7cf39762d6c8751dd3fe9d66bf"
            "40000000000ffffffff014041812f000000001976a91470730bda4463441b52a393ccced5aab0"
            "77cb4cae88ac02483045022100f3e47f61407c6d7f620c78ba56a65a285f7483e85f06da35014"
            "101808d75931c0220638a8a91fa8b1d747da9dc04730ed161c12e44f4e7e39ff9066e00277492"
            "468d41210358848ad624557628636d72e290c259478774504072b8504a6bb7ea7bb51c8d32000"
            "00000")

        self.assertEqual(expected, tx_hex)
示例#16
0
    def test_send_to_bech32(self):
        pk = PrivateKey.from_wif(
            "cTBQFX1uQDsc8EynnUbjqGp141Meh8bL25QCFxJDYRawkoShcs5S")

        utxo = Utxo(
            "5e802945886221fa9ab51ae00d8c412f5237220dfe60470de5580200453c1895",
            0, "ms8T2Mki2Cy4AkYZynnVVoXKnt4R87pXK3", 10, pk)

        spender = BCISpender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(9.993, "tb1qvnwx4vgelj3dlnp7s7uahaa45ck3esvh32eh80"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "020000000195183c45000258e50d4760fe0d2237522f418c0de01ab59afa2162884529805e0000"
            "00006b4830450221008b84ad2ef7d59cf7c0b49aad0a18b8da8e715f4609e1cd89f285daa6715b"
            "e3a7022057f2592aa709f8ee2d366aeb191b19993be36086e2807eafb3aff3d1764bcc8c412103"
            "4a41adc833d2c2c05596863e1eafb0d631ab47d03ebdc0d534de70bb8aa4301effffffff01a01b"
            "903b0000000016001464dc6ab119fca2dfcc3e87b9dbf7b5a62d1cc19700000000"
        )

        self.assertEqual(expected, tx_hex)
示例#17
0
    def test_spend_p2pkh_to_p2wpkh(self):
        pk = PrivateKey.from_wif(
            "91r82bjCYhYnimoCoqySeNk9AMaHFgPEedzXSCwb39vHiZLSBCQ")

        utxo = Utxo(
            "2df567a8aca645081cb1e56f3a28bdf37c4456b629b00768340afb393446cbf7",
            0, "n3WUs6uCpAc1at2u13ZLRQKf8wuqgVdZr4", 1.38, pk)

        spender = Spender()
        spender.add_utxos(utxo)
        spender.add_destinations(
            Destination(1.37, "tb1qfeytr2u0d3e3tny5kyjvjule3srx33eclcx6sy"))

        tx_hex = spender.create_tx().hex()

        expected = (
            "0200000001f7cb463439fb0a346807b029b656447cf3bd283a6fe5b11c0845a6aca867f52d00000000"
            "8a47304402207c6d8871605aea2d02955c04c67a41152ad7efaf28ceba25f74332a0ae252451022000"
            "e6762e9ce1ee968ed397756bfe18dfb2f185432056e2688bc180f9ec2bcadb014104dc406568adadd6"
            "93f302205af9694bf3caf3da0374f2183bea4680fb0d1f5cf5f06c2a78a0229129023260658e4e9f37"
            "d7d9e22fad81dfdbb944163138a82b68ffffffff0140742a08000000001600144e48b1ab8f6c7315cc"
            "94b124c973f98c0668c73800000000")

        self.assertEqual(expected, tx_hex)