当前位置: 首页>>代码示例>>Python>>正文


Python uint256.Uint256类代码示例

本文整理汇总了Python中coinpy.model.protocol.structures.uint256.Uint256的典型用法代码示例。如果您正苦于以下问题:Python Uint256类的具体用法?Python Uint256怎么用?Python Uint256使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Uint256类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_serialize_inv_message

 def test_serialize_inv_message(self):
     inv_message = InvMessage([Invitem(INV_TX, Uint256.from_hexstr("f6eea3dd4f6536350344a535e37a4178170bba18b871a424d696e196d4d3b555")),
                               Invitem(INV_BLOCK, Uint256.from_hexstr("0000000040a24e14497879bdd67db948cf30edc5d0a5833e8cb2736582157b49"))])
     serialized_msg = MessageSerializer(MAIN).serialize(inv_message)
     self.assertEquals(hexstr(serialized_msg), "f9beb4d9696e76000000000000000000490000008be920f5020100000055b5d3d496e196d624a471b818ba0b1778417ae335a544033536654fdda3eef602000000497b15826573b28c3e83a5d0c5ed30cf48b97dd6bd797849144ea24000000000")
     serialized_msg = MessageSerializer(TESTNET).serialize(inv_message)
     self.assertEquals(hexstr(serialized_msg), "fabfb5da696e76000000000000000000490000008be920f5020100000055b5d3d496e196d624a471b818ba0b1778417ae335a544033536654fdda3eef602000000497b15826573b28c3e83a5d0c5ed30cf48b97dd6bd797849144ea24000000000")
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:test_message_serializer.py

示例2: test_invitem_serialize

 def test_invitem_serialize(self):
     blockitem = Invitem(INV_BLOCK, Uint256.from_hexstr("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"))
     txitem = Invitem(INV_TX, Uint256.from_hexstr("84eb3cf3a391a0a0b70e05a3a54d8385f7dcb3809aaf274d392622205b27f288"))
     self.assertEquals(hexstr(InvitemSerializer().serialize(blockitem)), 
                       "0200000008b067b31dc139ee8e7a76a4f2cfcca477c4c06e1ef89f4ae308951907000000")
     self.assertEquals(hexstr(InvitemSerializer().serialize(txitem)), 
                       "0100000088f2275b202226394d27af9a80b3dcf785834da5a3050eb7a0a091a3f33ceb84")
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:test_structures.py

示例3: test_serialize_getblocks_message

 def test_serialize_getblocks_message(self):
     getblocks_msg = GetblocksMessage(BlockLocator(32200,
                                                   [Uint256.from_hexstr("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f")]), 
                                      Uint256.zero())
     
     serialized_msg = GetblocksMessageSerializer().serialize(getblocks_msg)
     self.assertEquals(hexstr(serialized_msg), "c87d0000016fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d61900000000000000000000000000000000000000000000000000000000000000000000000000")
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:test_messages.py

示例4: test_deserialize_getdata_message

 def test_deserialize_getdata_message(self):
     serialized_getdata = decodehexstr("030100000098a23359c17ca2678e2039c8ff9081b18c4913749c9a081ac3f62958f09fa4720100000055b5d3d496e196d624a471b818ba0b1778417ae335a544033536654fdda3eef602000000497b15826573b28c3e83a5d0c5ed30cf48b97dd6bd797849144ea24000000000")
     getdata_msg, _ = GetdataMessageSerializer().deserialize(serialized_getdata)
     expected_msg = GetdataMessage([Invitem(INV_TX, Uint256.from_hexstr("72a49ff05829f6c31a089a9c7413498cb18190ffc839208e67a27cc15933a298")),
                                   Invitem(INV_TX, Uint256.from_hexstr("f6eea3dd4f6536350344a535e37a4178170bba18b871a424d696e196d4d3b555")),
                                   Invitem(INV_BLOCK, Uint256.from_hexstr("0000000040a24e14497879bdd67db948cf30edc5d0a5833e8cb2736582157b49"))])
     self.assertEquals(getdata_msg, expected_msg)
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:test_messages.py

示例5: test_WalletFile_1

    def test_WalletFile_1(self):
        
        io = IoHandle.using_stringio()
        wallet = WalletFile.new(io)
        wallet.start_tx()
        wallet.outpoints[1]= OutpointIndex(12, 
                                 Uint256.from_hexstr("2af4cc9ec3358354345c91694031a1fcdbe9a9064197521814e8a20fe018eb5f"),
                                 3,
                                 OutpointIndex.PUBKEY_HASH,
                                 4,
                                 PubKeyOutpoint(PublicKey.from_hexstr("022af4cc9ec3358354345c91691031a1fcdbe9a9064197521814e8a20fe018eb5f"), 
                                                                is_pubkey_hash=True))
        wallet.end_tx()
        wallet.commit()
        wallet.start_tx()
        wallet.outpoints[1] = OutpointIndex(12, 
                                 Uint256.from_hexstr("2af4cc9ec3358354345c91694031a1fcdbe9a9064197521814e8a20fe018eb5f"),
                                 3,
                                 OutpointIndex.PUBKEY_HASH,
                                 4,
                                 PubKeyOutpoint(PublicKey.from_hexstr("022af4cc9ec3358354345c91691031a1fcdbe9a9064197521814e8a20fe018eb5f"), 
                                                                is_pubkey_hash=True))
        wallet.end_tx()
        wallet.commit()

        #with open(r"c:\local\tmp\wallet-test.wlt", "wb") as wlt:
        #    wlt.write(io.iohandle.getvalue())
        io.seek(0, SEEK_SET)
        wallet2 = WalletFile.load(io, len(io.iohandle.getvalue()))
        
        print wallet2.fileheader
        print wallet2.outpoints
开发者ID:sirk390,项目名称:coinpy,代码行数:32,代码来源:test_wallet_file.py

示例6: test_sign_transaction

    def test_sign_transaction(self):
        tx = Tx(version=1, 
                in_list=[TxIn(previous_output=Outpoint(hash=Uint256.from_hexstr("d2a42ebcb98b598ddcb6d430ce9061dba76804a97f7c1413dd3faef744f909a8"),index=0), 
                   script=Script(instructions=[]), 
                   sequence=4294967295),TxIn(previous_output=Outpoint(hash=Uint256.from_hexstr("2be8e319be1d15c1ba54708bdd7969b638e7e6fa2154819136e363ea6d33664a"),index=1), 
                   script=Script(instructions=[]), 
                   sequence=4294967295)], 
                out_list=[TxOut(value=3315075843, 
                    script=Script(instructions=[Instruction(OP_DUP),Instruction(OP_HASH160),Instruction(20,  decodehexstr("297c5a2ee31a1ab721115722d83f8654ca21d5df")),Instruction(OP_EQUALVERIFY),Instruction(OP_CHECKSIG)])),TxOut(value=2971972133, 
                    script=Script(instructions=[Instruction(OP_DUP),Instruction(OP_HASH160),Instruction(20,  decodehexstr("7d5feab86e31e8fc99d8e735d56226de9043e5fc")),Instruction(OP_EQUALVERIFY),Instruction(OP_CHECKSIG)])),TxOut(value=1046301823, 
                    script=Script(instructions=[Instruction(OP_DUP),Instruction(OP_HASH160),Instruction(20,  decodehexstr("fd91232a2fa0c389fa0188efde26c8a6165f4c50")),Instruction(OP_EQUALVERIFY),Instruction(OP_CHECKSIG)]))], 
                locktime=0)

        outscript0 = Script(instructions=[Instruction(33,  decodehexstr("03409fe679bdff9e801692c999b86d0c47b62dc02cdd10591ee70ca8056cd05023")),Instruction(OP_CHECKSIG)])
        outscript1 = Script(instructions=[Instruction(OP_DUP),Instruction(OP_HASH160),Instruction(20,  decodehexstr("5fb7fdb3d1ab0f3fec90b38417cca8ab736b10c6")),Instruction(OP_EQUALVERIFY),Instruction(OP_CHECKSIG)])

        # Sign TX_PUBKEY 
        sign_transaction(tx, 
                         [TxOut(None, outscript0), TxOut(None, outscript1)],
                         [decodehexstr("f006b27418527b1c400bbc434a3f22ee57c376bd4819cfe2a1162682788ae714"),
                          decodehexstr("c693115901c2840badd1e404706a4866a90d3afa16a542c1a3d0de9aad0875fe")])

        vm = TxValidationVM()
        valid, reason = vm.validate(tx, 0, outscript0, tx.in_list[0].script)
        if not valid:
            raise Exception(reason)
        valid, reason = vm.validate(tx, 1, outscript1, tx.in_list[1].script)
        if not valid:
            raise Exception(reason)
开发者ID:sirk390,项目名称:coinpy,代码行数:29,代码来源:test_sign_transaction.py

示例7: test_blocklocator_deserialize

 def test_blocklocator_deserialize(self):
     loc, cursor = BlockLocatorSerializer().deserialize(decodehexstr("0100000005a329e1166037b2ea0cfbef5060c011c1cbbd37ad047a47b62d3dae020000000070bdb41302a622800ddfb2b3ebdd937fdca812ec8a7ab90ef250410700000000398052b24b2cc45ef953222e23880d25c3df95a913e72e9b015b34250000000066739a04b15f117929b581f6fe0ba2906bc4323829400f949086bb7d0000000008b067b31dc139ee8e7a76a4f2cfcca477c4c06e1ef89f4ae308951907000000"))
     self.assertEquals(loc, BlockLocator(version=1,
                                         blockhashlist=[Uint256.from_hexstr("0000000002ae3d2db6477a04ad37bdcbc111c06050effb0ceab2376016e129a3"),
                                                        Uint256.from_hexstr("00000000074150f20eb97a8aec12a8dc7f93ddebb3b2df0d8022a60213b4bd70"),
                                                        Uint256.from_hexstr("0000000025345b019b2ee713a995dfc3250d88232e2253f95ec42c4bb2528039"),
                                                        Uint256.from_hexstr("000000007dbb8690940f40293832c46b90a20bfef681b52979115fb1049a7366"),
                                                        Uint256.from_hexstr("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008")]))
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:test_structures.py

示例8: test_blockheader_serialize

 def test_blockheader_serialize(self):
     h = BlockHeader(version=1, 
                     hash_prev=Uint256.from_hexstr("1e4baab89f3a3251818c31bc87f6a33b4a5a88ef76673e2cc77ab2127b7afded"), #hash_prev
                     hash_merkle=Uint256.from_hexstr("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"), #merkle
                     time=1237006505,
                     bits=486605799, 
                     nonce=2083236893) 
     self.assertEquals(hexstr(BlockheaderSerializer().serialize(h)), "01000000edfd7a7b12b27ac72c3e6776ef885a4a3ba3f687bc318c8151323a9fb8aa4b1e3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4aa938bb49e703011d1dac2b7c") 
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:test_structures.py

示例9: test_get_block_handle

 def test_get_block_handle(self):
     with self.assertRaises(BlockNotFound):
         self.database1.get_block_handle(Uint256.from_hexstr("041f9c93fece90e2e1f729bb9c2b04ba59432592f8ebdc7d117146c74f7c833a"))
     handle1 = self.database1.get_block_handle(Uint256.from_hexstr("001f9c93fece90e2e1f729bb9c2b04ba59432592f8ebdc7d117146c74f7c833a"))
     self.assertEquals(handle1.get_height(), 4)
     self.assertEquals(handle1.get_hash(), Uint256.from_hexstr("001f9c93fece90e2e1f729bb9c2b04ba59432592f8ebdc7d117146c74f7c833a"))
     assert isinstance(handle1.get_block(), Block)
     assert isinstance(handle1.get_blockheader(), BlockHeader)
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:test_memory_blockchain.py

示例10: test_mine_genesis_block

 def test_mine_genesis_block(self):
     """ Mine the unitnet GENESIS block """
     time_source = MockTimeSource(time=1356446436)
     miner = BitcoinMiner()
     block, template = miner.mine_block(hash_prev=Uint256.from_hexstr("0000000000000000000000000000000000000000000000000000000000000000"), 
                                 block_height=0,
                                 time_source=time_source, 
                                 difficulty_bits=524287999, 
                                 transactions=[], 
                                 coinbase_txout_list=[TxOut(5000000000, Script([push_data_instruction(decodehexstr("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f")),Instruction(OP_CHECKSIG)]))],
                                 coinbase_flags=["/P2SH/", "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks"])
     self.assertEquals(block.blockheader.nonce, 1260)
     self.assertEquals(block.blockheader.hash_merkle, Uint256.from_hexstr("cf7ac9a3b387cf5e9fc14e03e2a5bbfc16d1ba00d2af6c96869ab4da949bd240"))
     self.assertEquals(hash_block(block), Uint256.from_hexstr("003ee3cf880906caa5662f10d4b4fb1c86c1853230dee8a7b8a62f434c73da5f"))
开发者ID:sirk390,项目名称:coinpy,代码行数:14,代码来源:test_mining.py

示例11: hash_tx

def hash_tx(tx):
    if tx.hash:
        return tx.hash
    if not tx.rawdata:
        tx.rawdata = TX_SERIALIZE.serialize(tx)
    tx.hash = Uint256.from_bytestr(doublesha256(tx.rawdata))
    return tx.hash
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:hash_tx.py

示例12: test_txin_serialize

 def test_txin_serialize(self):
     txin = TxIn(previous_output=Outpoint(hash=Uint256.from_hexstr("17c5cb687ba453ab65e12cdc0d8721c70ab4678665eb200c50cb9f1e3207090e"), index=0), 
                            script=Script([Instruction(72, decodehexstr("3045022100ab2dc8932ca1d26f4cdac1feae09020a60ccc4d17b14e5fc5b21f3ab8c3a9cee022040a7208c172d19a19902280d66201c7fe2c3d8b2df7e23cc4e5b70fd52ecba2c01")),
                                           Instruction(65, decodehexstr("04b77dd1f3a21cb3d067a7e76982a609d7310f8692f5d61346f3225323c425604a0c12862755335c49e392673106adfc5dfdee1e4d367f10353e8911fac687db3e"))]), 
                            sequence=TxIn.NSEQUENCE_FINAL)
     self.assertEquals(hexstr(TxinSerializer().serialize(txin)), 
                       "0e0907321e9fcb500c20eb658667b40ac721870ddc2ce165ab53a47b68cbc517000000008b483045022100ab2dc8932ca1d26f4cdac1feae09020a60ccc4d17b14e5fc5b21f3ab8c3a9cee022040a7208c172d19a19902280d66201c7fe2c3d8b2df7e23cc4e5b70fd52ecba2c014104b77dd1f3a21cb3d067a7e76982a609d7310f8692f5d61346f3225323c425604a0c12862755335c49e392673106adfc5dfdee1e4d367f10353e8911fac687db3effffffff")
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:test_structures.py

示例13: get_next_in_mainchain

 def get_next_in_mainchain(self, blockhash):
     if not self.indexdb.contains_block(blockhash):
         raise BlockNotFound(str(blockhash))
     blockindex = self.indexdb.get_blockindex(blockhash)
     if (blockindex.hash_next == Uint256.zero()):
         return None
     return blockindex.hash_next
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:db_blockchain.py

示例14: hash_blockheader

def hash_blockheader(blockheader):
    if blockheader.hash:
        return blockheader.hash
    if not blockheader.rawdata:
        blockheader.rawdata = BLOCK_SERIALIZE.serialize(blockheader)
    blockheader.hash = Uint256.from_bytestr(doublesha256(blockheader.rawdata))
    return blockheader.hash
开发者ID:sirk390,项目名称:coinpy,代码行数:7,代码来源:hash_block.py

示例15: _find_fork

 def _find_fork(self, altchainhash):
     hash = altchainhash
     while hash != Uint256.zero():
         handle = self.get_block_handle(hash)
         if handle.is_mainchain():
             return hash
         hash = handle.get_blockheader().hash_prev 
     return handle.hash
开发者ID:sirk390,项目名称:coinpy,代码行数:8,代码来源:db_blockchain.py


注:本文中的coinpy.model.protocol.structures.uint256.Uint256类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。