Exemplo n.º 1
0
    def serialize_header(self, res):
        s = int_to_hex(res.get('version'), 4) \
            + rev_hex(self.get_block_hash(res)) \
            + rev_hex(res.get('merkle_root')) \
            + rev_hex(res.get('claim_trie_root')) \
            + int_to_hex(int(res.get('timestamp')), 4) \
            + int_to_hex(int(res.get('bits')), 4) \
            + int_to_hex(int(res.get('nonce')), 4)

        return s
Exemplo n.º 2
0
    def serialize_header(self, res):
        s = int_to_hex(res.get('version'), 4) \
            + rev_hex(self.get_block_hash(res)) \
            + rev_hex(res.get('merkle_root')) \
            + rev_hex(res.get('claim_trie_root')) \
            + int_to_hex(int(res.get('timestamp')), 4) \
            + int_to_hex(int(res.get('bits')), 4) \
            + int_to_hex(int(res.get('nonce')), 4)

        return s
Exemplo n.º 3
0
 def get_claim_id(self, nout):
     if nout < 0:
         raise IndexError
     if not self._outputs[nout][0] & TYPE_CLAIM:
         raise ValueError
     tx_hash = rev_hex(self.hash()).decode('hex')
     return encode_claim_id_hex(claim_id_hash(tx_hash, nout))
Exemplo n.º 4
0
 def get_claim_id(self, nout):
     if nout < 0:
         raise IndexError
     if not self._outputs[nout][0] & TYPE_CLAIM:
         raise ValueError
     tx_hash = rev_hex(self.hash()).decode('hex')
     return encode_claim_id_hex(claim_id_hash(tx_hash, nout))
Exemplo n.º 5
0
 def parse_xpubkey(cls, pubkey):
     assert is_extended_pubkey(pubkey)
     pk = pubkey.decode('hex')
     pk = pk[1:]
     xkey = EncodeBase58Check(pk[0:78])
     dd = pk[78:]
     s = []
     while dd:
         n = int(rev_hex(dd[0:2].encode('hex')), 16)
         dd = dd[2:]
         s.append(n)
     assert len(s) == 2
     return xkey, s
Exemplo n.º 6
0
 def parse_xpubkey(cls, pubkey):
     assert is_extended_pubkey(pubkey)
     pk = pubkey.decode('hex')
     pk = pk[1:]
     xkey = b58encode_with_checksum(pk[0:78])
     dd = pk[78:]
     s = []
     while dd:
         n = int(rev_hex(dd[0:2].encode('hex')), 16)
         dd = dd[2:]
         s.append(n)
     assert len(s) == 2
     return xkey, s
Exemplo n.º 7
0
 def test_claimid_hash(self):
     txid = "4d08012feefec192bdb45495dcedc171a56d369539ce2d589e3e1ec81a882bb4"
     nout = 1
     claim_id = "a438fc7701e10e0e5c41d7a342be1190d9bed57b"
     out = claim_id_hash(rev_hex(txid).decode('hex'), nout)
     self.assertEqual(claim_id, rev_hex(out.encode('hex')))
Exemplo n.º 8
0
 def test_claimid_hash(self):
     txid = "4d08012feefec192bdb45495dcedc171a56d369539ce2d589e3e1ec81a882bb4"
     nout = 1
     claim_id = "a438fc7701e10e0e5c41d7a342be1190d9bed57b"
     out = claim_id_hash(rev_hex(txid).decode('hex'), nout)
     self.assertEqual(claim_id, rev_hex(out.encode('hex')))
Exemplo n.º 9
0
def CKD_pub(cK, c, n):
    if n & BIP32_PRIME:
        raise Exception("CKD pub error")
    return _CKD_pub(cK, c, rev_hex(int_to_hex(n, 4)).decode('hex'))
Exemplo n.º 10
0
def CKD_priv(k, c, n):
    is_prime = n & BIP32_PRIME
    return _CKD_priv(k, c, rev_hex(int_to_hex(n, 4)).decode('hex'), is_prime)
Exemplo n.º 11
0
def encode_claim_id_hex(claim_id):
    return rev_hex(claim_id.encode('hex'))
Exemplo n.º 12
0
def decode_claim_id_hex(claim_id_hex):
    return rev_hex(claim_id_hex).decode('hex')
Exemplo n.º 13
0
def CKD_pub(cK, c, n):
    if n & BIP32_PRIME:
        raise Exception("CKD pub error")
    return _CKD_pub(cK, c, rev_hex(int_to_hex(n, 4)).decode('hex'))
Exemplo n.º 14
0
def CKD_priv(k, c, n):
    is_prime = n & BIP32_PRIME
    return _CKD_priv(k, c, rev_hex(int_to_hex(n, 4)).decode('hex'), is_prime)
Exemplo n.º 15
0
def encode_claim_id_hex(claim_id):
    return rev_hex(claim_id.encode('hex'))
Exemplo n.º 16
0
def decode_claim_id_hex(claim_id_hex):
    claim_id = rev_hex(claim_id_hex).decode('hex')
    if len(claim_id) != CLAIM_ID_SIZE:
        raise InvalidClaimId()
    return claim_id