Exemplo n.º 1
0
def sign_transfer(private_key: str, tx: TransferToken) -> dict:
    from lunespy.crypto import fast_signature
    from lunespy.crypto import b58_to_bytes, bytes_to_b58

    tx.message = bytes_to_b58(serialize_transfer(tx))

    return bytes_to_b58(
        fast_signature(b58_to_bytes(private_key), b58_to_bytes(tx.message)))
Exemplo n.º 2
0
def sign_issue(private_key: str, tx: IssueToken) -> str:
    from lunespy.crypto import fast_signature
    from lunespy.crypto import b58_to_bytes, bytes_to_b58

    tx.message = bytes_to_b58(serialize_issue(tx))

    return bytes_to_b58(
        fast_signature(b58_to_bytes(private_key), b58_to_bytes(tx.message)))
Exemplo n.º 3
0
def from_private_key(private_key: str, chain: int = 1):
    from lunespy.crypto import bytes_to_b58, b58_to_bytes, to_address, to_private_key, to_public_key
    from lunespy.wallet import Wallet

    private_key: bytes = to_private_key(b58_to_bytes(private_key))
    public_key: bytes = to_public_key(private_key)
    address: bytes = to_address(public_key, chain, 1)

    return Wallet(private_key=bytes_to_b58(private_key),
                  public_key=bytes_to_b58(public_key),
                  address=bytes_to_b58(address),
                  seed_len=0,
                  nonce=0,
                  chain=chain,
                  seed="")
Exemplo n.º 4
0
def from_seed(seed: str, nonce: int, chain: int):
    from lunespy.crypto import bytes_to_b58, to_address, to_private_key, to_public_key, hidden_seed
    from lunespy.wallet import Wallet

    hash_seed: bytes = hidden_seed(nonce, seed)
    private_key: bytes = to_private_key(hash_seed)
    public_key: bytes = to_public_key(private_key)
    address: bytes = to_address(public_key, chain, 1)

    return Wallet(private_key=bytes_to_b58(private_key),
                  public_key=bytes_to_b58(public_key),
                  address=bytes_to_b58(address),
                  nonce=nonce,
                  chain=chain,
                  seed=seed)
Exemplo n.º 5
0
def transfer_token_factory(sender_public_key: str,
                           receiver_address: str,
                           amount: float,
                           chain: int = 1,
                           asset_id: str = "",
                           **kwargs: dict) -> TransferToken:
    from lunespy.crypto import b58_to_bytes, bytes_to_b58, to_address

    return TransferToken(sender=bytes_to_b58(
        to_address(b58_to_bytes(sender_public_key), chain, 1)),
                         amount=int(amount * 10e7),
                         senderPublicKey=sender_public_key,
                         recipient=receiver_address,
                         assetId=asset_id,
                         **kwargs)