Exemple #1
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="")
Exemple #2
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)
Exemple #3
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)
Exemple #4
0
def test_generate_private_key_for_0_1_2_3_4_nonces(public_key,
                                                   address_testnet):
    assert address_testnet == list(
        to_address(public_key=bytes(public_key), chain=0, addr_version=1))