Пример #1
0
def sign_message(message, secret):
    signature = MessageSignature()
    message = DataChunk(message)
    assert isinstance(secret, EcPrivate)
    if lib.bc_sign_message(signature._obj, message._obj, secret._obj) != 1:
        return None
    return signature.data
Пример #2
0
 def from_data(cls, encoded, prefix):
     data = DataChunk(encoded)
     self = cls()
     result = lib.bc_script__from_data(self._obj, data._obj, prefix) == 1
     if not result:
         return None
     return self
Пример #3
0
 def from_data(cls, uncoded, minimal=True):
     data = DataChunk(uncoded)
     if minimal:
         obj = lib.bc_create_operation_Data(data._obj)
     else:
         obj = lib.bc_create_operation_Data_nominimal(data._obj)
     return cls(obj)
Пример #4
0
def verify_message(message, address, signature):
    message = DataChunk(message)
    if isinstance(address, str):
        address = PaymentAddress(address)
    assert isinstance(address, PaymentAddress)
    signature = MessageSignature.from_bytes(signature)
    return lib.bc_verify_message(message._obj, address._obj, signature._obj) \
        == 1
Пример #5
0
 def check_signature(signature, sighash_type, public_key, script_code, tx,
                     input_index):
     public_key = DataChunk(public_key)
     return lib.bc_script__check_signature(signature._obj,
                                           sighash_type.value,
                                           public_key._obj,
                                           script_code._obj, tx._obj,
                                           input_index) == 1
Пример #6
0
 def from_data(cls, data, wire=True):
     data = DataChunk(data)
     self = cls()
     if wire:
         result = lib.bc_transaction__from_data(self._obj, data._obj)
     else:
         result = lib.bc_transaction__from_data_nowire(self._obj, data._obj)
     if result != 1:
         return None
     return self
Пример #7
0
def create_mnemonic(entropy, lexicon=None):
    """Create a new mnenomic (list of words) from provided entropy
    and a dictionary selection. The mnemonic can later be converted to
    a seed for use in wallet creation. Entropy byte count must be
    evenly divisible by 4."""
    entropy = DataChunk(entropy)
    if lexicon is None:
        obj = lib.bc_create_mnemonic(entropy._obj)
    else:
        obj = lib.bc_create_mnemonic_Dict(entropy._obj, lexicon._obj)
    return [str(word) for word in StringList(obj)]
Пример #8
0
 def to_null_data_pattern(data):
     data = DataChunk(data)
     obj = lib.bc_script__to_null_data_pattern(data._obj)
     return list(OperationList(obj))
Пример #9
0
 def to_chunk(self):
     obj = lib.bc_stealth_address__to_chunk(self._obj)
     return DataChunk(obj).data
Пример #10
0
 def blocks(self):
     obj = lib.bc_binary__blocks(self._obj)
     return DataChunk(obj).data
Пример #11
0
 def to_data(self):
     obj = lib.bc_point__to_data(self._obj)
     return DataChunk(obj)
Пример #12
0
 def from_data(cls, decoded):
     decoded = DataChunk(decoded)
     obj = lib.bc_create_stealth_address_Data(decoded._obj)
     return cls(obj)
Пример #13
0
 def data(self):
     obj = lib.bc_operation__data(self._obj)
     return DataChunk(obj).data
Пример #14
0
 def from_data(cls, data):
     data = DataChunk(data)
     obj = lib.bc_point__factory_from_data(data._obj)
     return cls(obj)
Пример #15
0
 def from_data(cls, size, blocks):
     blocks = DataChunk(blocks)
     obj = lib.bc_create_binary_Blocks(size, blocks._obj)
     return cls(obj)
Пример #16
0
 def encode(self):
     out = DataChunk()
     if lib.bc_encode_signature(out._obj, self._obj) == 0:
         return None
     return out.data
Пример #17
0
 def from_seed(cls, seed, prefixes):
     seed = DataChunk(seed)
     obj = lib.bc_create_hd_private_Seed(seed._obj, prefixes)
     return cls(obj)
Пример #18
0
def create_ephemeral_key(seed):
    out_secret = EcSecret()
    seed = DataChunk(seed)
    if lib.bc_create_ephemeral_key(out_secret._obj, seed._obj) != 1:
        return None
    return out_secret
Пример #19
0
def hash_message(message):
    message = DataChunk(message)
    return lib.hash_message(message._obj)
Пример #20
0
def bitcoin_hash(data):
    data = DataChunk(data)
    obj = lib.bc_bitcoin_hash(data._obj)
    return HashDigest(obj)
Пример #21
0
 def to_data(self):
     obj = lib.bc_header__to_data(self._obj)
     return DataChunk(obj).data
Пример #22
0
 def to_pay_public_key_pattern(data):
     data = DataChunk(data)
     obj = lib.bc_script__to_pay_public_key_pattern(data._obj)
     return list(OperationList(obj))
Пример #23
0
 def data(self):
     obj = lib.bc_machine_number__data(self._obj)
     return DataChunk(obj).data
Пример #24
0
 def find_and_delete(self, endorsements):
     stack = DataStack()
     for endorse in endorsements:
         endorse = DataChunk(endorse)
         stack.append(endorse)
     lib.bc_script__find_and_delete(self._obj, stack._obj)
Пример #25
0
 def to_data(self):
     obj = lib.bc_output__to_data(self._obj)
     return DataChunk(obj).data
Пример #26
0
 def to_data(self, prefix):
     obj = lib.bc_script__to_data(self._obj, prefix)
     return DataChunk(obj).data
Пример #27
0
 def to_data(self, wire=True):
     if wire:
         obj = lib.bc_transaction__to_data(self._obj)
     else:
         obj = lib.bc_transaction__to_data_nowire(self._obj)
     return DataChunk(obj).data
Пример #28
0
def create_stealth_data(filter_, seed):
    out_stealth_data = DataChunk()
    out_secret = EcSecret()
    #TODO: unsure how to work with filter and binary type
    assert False
Пример #29
0
 def from_der(cls, data, strict):
     der = DataChunk(data)
     out = EcSignature()
     if lib.bc_parse_signature(out._obj, der._obj, strict) == 0:
         return None
     return out