Skip to main content

Python wrappers around the Grin wallet V3 and Grin node V2 APIs

Project description

grinmw.py

Grin is a privacy-preserving digital currency built openly by developers distributed all over the world. Check grin.mw to know more!

This module provides Python wrappers for

Install with

pip install grinmw

If you need help please check how to reach our community.

Examples

Using the Node V2 API to access the locally running Grin node.

from grinmw.node_v2 import NodeV2

import pprint
from pathlib import Path
home = str(Path.home())

pp = pprint.PrettyPrinter(indent=4)
owner_api_url = 'http://localhost:3413/v2/owner'

# change to your grin owner_api secret file
owner_api_sercet_file = os.path.join(home, '.grin/main/.api_secret')
owner_api_user = 'grin'
owner_api_password = open(owner_api_sercet_file).read().strip()

foreign_api_url = 'http://localhost:3413/v2/foreign'

# change to your grin owner_api sercret file
foreign_api_sercet_file = os.path.join(home, '.grin/main/.foreign_api_secret')
foreign_api_user = 'grin'
foreign_api_password = open(foreign_api_sercet_file).read().strip()

node = NodeV2( foreign_api_url, foreign_api_user, foreign_api_password, owner_api_url, owner_api_user, owner_api_password)
pp.pprint(node.get_status())
pp.pprint(node.get_header(1036985))
pp.pprint(node.get_kernel('096a7303ab9e3a68cf0b3d70d6ec61311efaf0f33f2ac251bff2a4da45908d3f15'))
pp.pprint(node.get_kernel('08f0a2b7e3ddd0ccc60ac147e93f3e8b01ede591d0da08ba93333e3c73fd45c1cf'))

Using the Wallet V3 API to access the locally running Grin wallet listener.

from grinmw.wallet_v3 import WalletV3

import pprint, os

pp = pprint.PrettyPrinter(indent=4)
api_url = 'http://localhost:3420/v3/owner'

# change to your grin owner_api sercret file
api_sercet_file = '/home/ubuntu/.grin/main/.owner_api_secret'
api_user = 'grin'
api_password = open(api_sercet_file).read().strip()
wallet = WalletV3(api_url, api_user, api_password)
wallet.init_secure_api()

# change to you wallet password
wallet_password = '123'

wallet.open_wallet(None, wallet_password)
pp.pprint(wallet.node_height())
pp.pprint(wallet.get_slatepack_address())

# send to gate.io
send_args = {
    'src_acct_name': None,
    'amount': int(2.67020546 * 1000000000),
    'minimum_confirmations': 10,
    'max_outputs': 500,
    'num_change_outputs': 1,
    'selection_strategy_is_use_all': False,
    'target_slate_version': None,
    'payment_proof_recipient_address': 'grin1n26np6apy07576qx6yz4qayuwxcpjvl87a2mjv3jpk6mnyz8y4vq65ahjm',
    'ttl_blocks': None,
    'send_args': {
        "dest": 'grin1n26np6apy07576qx6yz4qayuwxcpjvl87a2mjv3jpk6mnyz8y4vq65ahjm',
        "post_tx": True,
        "fluff": True,
        "skip_tor": False
    }
}
print(wallet.init_send_tx(send_args))

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

grinmw-0.1.1.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file grinmw-0.1.1.tar.gz.

File metadata

  • Download URL: grinmw-0.1.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.8.2

File hashes

Hashes for grinmw-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8764647d00abe7a761168ab17a04a3061d4dfb94dffafecda0be6bade43c6769
MD5 9f164efd10a1f821996a03e7a9dd1f5e
BLAKE2b-256 0aa53017c103c5aae14f58f026642c3994730ab2dc9e993ddf25bf89d2db2100

See more details on using hashes here.

Supported by

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