Skip to main content

Tools for tendermint-based wallet management, offline transaction signing and broadcasting

Project description

tendermintwallet

Version 0.0.1

Tools for Tendermint-based wallet management, offline transaction signing, and broadcast through an RPC.

Installing

Installing from PyPI Coming Soon repository:

# pip3 install TendermintWallet

Installing from source code:

git clone https://github.com/algo-vaultstaking/tendermintwallet
cd tendermintwallet
pip3 install .

Usage

Generating a wallet

from tendermintwallet import generate_wallet
wallet = generate_wallet()

The value assigned to wallet will be a dictionary just like:

{
    "seed": "arch skill acquire abuse frown reject front second album pizza hill slogan guess random wonder benefit industry custom green ill moral daring glow elevator",
    "derivation_path": "m/44'/118'/0'/0/0",
    "private_key": b'\xbb\xec^\xf6\xdcg\xe6\xb5\x89\xed\x8cG\x05\x03\xdf0:\xc9\x8b \x85\x8a\x14\x12\xd7\xa6a\x01\xcd\xf8\x88\x93',
    "public_key": b"\x03h\x1d\xae\xa7\x9eO\x8e\xc5\xff\xa3sAw\xe6\xdd\xc9\xb8b\x06\x0eo\xc5a%z\xe3\xff\x1e\xd2\x8e5\xe7",
    "address": "comdex1uuhna3psjqfxnw4msrfzsr0g08yuyfxesqggqd",
}

Converter functions

Mnemonic seed to private key

from tendermintwallet import seed_to_privkey
seed = "teach there dream chase fatigue abandon lava super senior artefact close upgrade"
privkey = seed_to_privkey(seed, path="m/44'/118'/0'/0/0")

Private key to public key

from tendermintwallet import privkey_to_pubkey
privkey = bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")
pubkey = privkey_to_pubkey(privkey)

Public key to address

from tendermintwallet import pubkey_to_address
pubkey = bytes.fromhex("03e8005aad74da5a053602f86e3151d4f3214937863a11299c960c28d3609c4775")
addr = pubkey_to_address(pubkey)

Private key to address

from tendermintwallet import privkey_to_address
privkey = bytes.fromhex("6dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515afa")
addr = privkey_to_address(privkey)

Address to address

from tendermintwallet import address_to_address
addr = address_to_address(address, prefix)

Signing transactions

Send transaction

from tendermintwallet import Transaction
tx = Transaction(
    privkey=bytes.fromhex("26d167d549a4b2b66f766b0d3f2bdbe1cd92708818c338ff453abde316a2bd59"),
    account_num=11335,
    sequence=0,
    fee=0,
    gas=200000,
    memo="",
    chain_id="comdex-1",
    sync_mode="broadcast_tx_sync", # "broadcast_tx_sync", "broadcast_tx_async", "broadcast_tx_commit"
)
tx.add_transfer(recipient="comdex103l758ps7403sd9c0y8j6hrfw4xyl70j4mmwkf", amount=387000)
tx.add_transfer(recipient="comdex1lzumfk6xvwf9k9rk72mqtztv867xyem393um48", amount=123)

One or more token transfers can be added to a transaction by calling the add_transfer method.

When the transaction is fully prepared, calling get_pushable will return a signed transaction in the form of a JSON string.

pushable_tx = tx.get_pushable()

This can be used as request body when calling endpoint of the https://rpc_api:26657, more detailes here

import requests

res = requests.post(url=<rpc_api>, data=pushable_tx)

Or you can call broadcast(rps: str) method and it will make a signed transaction and POST it with defined RPC_api.

res = tx.broadcast(url=<RPC_api>)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tendermintwallet-0.0.1.tar.gz (18.2 kB view details)

Uploaded Source

File details

Details for the file tendermintwallet-0.0.1.tar.gz.

File metadata

  • Download URL: tendermintwallet-0.0.1.tar.gz
  • Upload date:
  • Size: 18.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for tendermintwallet-0.0.1.tar.gz
Algorithm Hash digest
SHA256 e3b35944c37a49a789e029fdd4db0ad51860703674ca33222cc5b9ec9effef3b
MD5 d824f15e7994b5c221c1b4f841356616
BLAKE2b-256 4574ee347fbd5db313895036f11eaab8de6f5a0d133e98262c324f2a09a35892

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page