Esempio n. 1
0
    def testSegwitTx(self):
        txhash = "85b2c5e202950eb7dc87ff570d68e366d02a801759283c8c8ca66986e7f25242"
        wtxhash = "da9f24ac73ba45e28f87510b9515e7ab6591d3a86aec6b59d5447cdf2e22ca38"
        b = BytesIO(
            open(os.path.join(BASENAME, 'resources', "segwit-tx.dmp")).read())
        t = messages.TxPacket()
        self.assertTrue(t.parse(b, {'segwit': True}))
        self.assertEquals(b.tell(), len(b.getvalue()))

        self.assertEquals(txhash, t.hash().encode('hex'))

        self.assertEquals(11, len(t.inputs))
        self.assertEquals(11, len(t.outputs))
        self.assertEquals(t.lock_time, 0)
        self.assertEquals(11, len(t.witnesses))
        self.assertTrue(t.is_segwit)
        self.assertFalse(t.is_coinbase())

        buf = BytesIO()
        opts = {'segwit': True, 'version': 70001}
        t.toWire(buf, opts)
        self.assertEquals(b.getvalue().encode("hex"),
                          buf.getvalue().encode("hex"))

        self.assertEquals(wtxhash, t.whash().encode('hex'))
Esempio n. 2
0
    def testSegwitTx(self):
        txhash = "85b2c5e202950eb7dc87ff570d68e366d02a801759283c8c8ca66986e7f25242"
        wtxhash = "da9f24ac73ba45e28f87510b9515e7ab6591d3a86aec6b59d5447cdf2e22ca38"
        b = BytesIO(open(
            os.path.join(BASENAME, 'resources', "segwit-tx.dmp")
        ).read())
        t = messages.TxPacket()
        self.assertTrue(t.parse(b, {'segwit': True}))
        self.assertEquals(b.tell(), len(b.getvalue()))

        self.assertEquals(txhash, t.hash().encode('hex'))
        
        self.assertEquals(11, len(t.inputs))
        self.assertEquals(11, len(t.outputs))
        self.assertEquals(t.lock_time, 0)
        self.assertEquals(11, len(t.witnesses))
        self.assertTrue(t.is_segwit)
        self.assertFalse(t.is_coinbase())

        buf = BytesIO()
        opts = {'segwit': True, 'version': 70001}
        t.toWire(buf, opts)
        self.assertEquals(
            b.getvalue().encode("hex"),
            buf.getvalue().encode("hex")
        )

        self.assertEquals(wtxhash, t.whash().encode('hex'))
Esempio n. 3
0
 def testTxPacket(self):
     from bitcoin.BitcoinProtocol import TxPacket
     b = BytesIO(open("test/resources/tx-9c0f7b2.dmp").read())
     t = TxPacket()
     t.parse(b)
     self.assertEquals(b.tell(), len(b.getvalue()))
     
     self.assertEquals(1, len(t.inputs))
     self.assertEquals(2, len(t.outputs))
     self.assertEquals(t.lock_time, 0)
     
     buf = BytesIO()
     t.toWire(buf)
     self.assertEquals(b.getvalue().encode("hex"), buf.getvalue().encode("hex"))
Esempio n. 4
0
    def testTxPacket(self):
        b = BytesIO(
            open(os.path.join(BASENAME, 'resources', "tx-9c0f7b2.dmp")).read())
        t = messages.TxPacket()
        t.parse(b, None)
        self.assertEquals(b.tell(), len(b.getvalue()))

        self.assertEquals(1, len(t.inputs))
        self.assertEquals(2, len(t.outputs))
        self.assertEquals(t.lock_time, 0)

        buf = BytesIO()
        t.toWire(buf, {'version': 70001})
        self.assertEquals(b.getvalue().encode("hex"),
                          buf.getvalue().encode("hex"))
Esempio n. 5
0
    def testTxPacket(self):
        from bitcoin.BitcoinProtocol import TxPacket
        b = BytesIO(open("test/resources/tx-9c0f7b2.dmp").read())
        t = TxPacket()
        t.parse(b)
        self.assertEquals(b.tell(), len(b.getvalue()))

        self.assertEquals(1, len(t.inputs))
        self.assertEquals(2, len(t.outputs))
        self.assertEquals(t.lock_time, 0)

        buf = BytesIO()
        t.toWire(buf)
        self.assertEquals(b.getvalue().encode("hex"),
                          buf.getvalue().encode("hex"))
Esempio n. 6
0
    def testTxPacket(self):
        b = BytesIO(open(
            os.path.join(BASENAME, 'resources', "tx-9c0f7b2.dmp")
        ).read())
        t = messages.TxPacket()
        t.parse(b, None)
        self.assertEquals(b.tell(), len(b.getvalue()))

        self.assertEquals(1, len(t.inputs))
        self.assertEquals(2, len(t.outputs))
        self.assertEquals(t.lock_time, 0)

        buf = BytesIO()
        t.toWire(buf, {'version': 70001})
        self.assertEquals(
            b.getvalue().encode("hex"),
            buf.getvalue().encode("hex")
        )