Skip to main content

Package for transaction offline transaction signing

Project description

libopy

Installing

Installing from PyPI repository (https://pypi.org/project/libopy):

pip install libopy

Usage

Generating a wallet

from libopy import generate_wallet

wallet = generate_wallet()

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

{
    "seed": "YOUR_MNEMONIC_SEED",
    "derivation_path": "m/44'/118'/0'/0/0",
    "private_key": b"\xcc\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"\x13\x1d\xae\xa7\x9eO\x8e\xc5\xff\xa3sAw\xe6\xdd\xc9\xb8b\x06\x0eo\xc5a%z\xe3\xff\x1e\xd2\x8e5\xe7",
    "address": "libonomy5byhna3psjqfxnw4msrfzsr0g08yuyfxeht0qak",
}

Converter functions

Mnemonic seed to private key

from libopy import BIP32DerivationError, seed_to_privkey

seed = (
    "YOUR_MNEMONIC_SEED"
)
try:
    privkey = seed_to_privkey(seed, path="m/44'/118'/0'/0/0")
except BIP32DerivationError:
    print("No valid private key in this derivation path!")

Private key to public key

from libopy import privkey_to_pubkey

privkey = bytes.fromhex(
    "1dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515ala"
)
pubkey = privkey_to_pubkey(privkey)

Public key to address

from libopy import pubkey_to_address

pubkey = bytes.fromhex(
    "1dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515ala"
)
addr = pubkey_to_address(pubkey)

Private key to address

from libopy import privkey_to_address

privkey = bytes.fromhex(
    "1dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515ala"
)
addr = privkey_to_address(privkey)

Signing transactions

from libopy import Transaction

tx = Transaction(
    privkey=bytes.fromhex(
        "1dcd05d7ac71e09d3cf7da666709ebd59362486ff9e99db0e8bc663570515ala"
    ),
    account_num=0,
    sequence=0,
    fee=0,
    gas=0,
    memo="",
    chain_id="chain-id",
    sync_mode="sync",
)
tx.add_transfer(
    recipient="libonomy5byhna3psjqfxnw4msrfzsr0g08yuyfxeht0qak", amount=1000000 
)
tx.add_transfer(recipient="libonomy5byhna3psjqfxnw4msrfzsr0g08yuyfxeht0qak", amount=1000000)
pushable_tx = tx.get_pushable()

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. This can be used as request body when calling the POST /txs endpoint.

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

libopy-1.0.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libopy-1.0.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file libopy-1.0.0.tar.gz.

File metadata

  • Download URL: libopy-1.0.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for libopy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5f19cf41dc067faefd809255dcaeae9619a8e05049c4c36c826b66050b0ec1b2
MD5 9a89fe4ea408baaffaa9e681658d446b
BLAKE2b-256 e5c76d319b43dde4af3cfa30aacf588a89a19de6aabfd96f404ab62df41378dd

See more details on using hashes here.

File details

Details for the file libopy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: libopy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5

File hashes

Hashes for libopy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 14357c68070dfc8fb9d40089ad122639fa9c8f686ba3df12aead319ae153ed7c
MD5 61d0c9e194a996653d5ab2d5f7a92e7d
BLAKE2b-256 6f3306765f4e2927a591ba39f7002e7a54062a6d6e7cc9164ae173be74250fcb

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