Skip to main content

Python helper package for interacting with your Samourai Dojo instance

Project description

Dojo-py

A very incomplete interface to your Samourai Dojo REST API.

  • All requests are proxied through SOCKS to your Dojo's Tor hidden service URL
  • Authenticated calls to the Dojo make use of the Authorization HTTP header with the Bearer scheme.

Get Started

Install from pip

pip install dojo-py

Setup

## Import the package
from pydojo import pyDojo

## Set two variables for onion address and API key.
## Both can be obtained from your Dojo Maintenance Tool
## or your pairing QR code
onion = 'mytorv3onionaddress.onion'
apikey = 'mydojoapikey'
pd = pyDojo(onion, apikey)

Status

## Get Dojo Status
## NOTE: this call requires use of the Admin Key instead 
## of the API Key
pd.get_status()

Fees

## Get current miner fee rates as per your Dojo
pd.get_fees()

Block header

## Get information about a certain block header
blockhash = '0000000000000000000a0c3d6bbc0168932613d550cb7875459b6d37ae088211'
pd.get_block_header(blockhash)

Add extended public key to your Dojo

## Add a new extended public key to your Dojo
## You must tell the Dojo how to derive addresses
## if it is a Segwit enabled public key. `bip49` or `bip84`
## You also need to supply a method of import. Valid values 
## are `new` and `restore`.

xpub = 'ypub...'
method = 'restore'
segwit = 'bip49'

pd.add_xpub(xpub=xpub, type=method, segwit=segwit)

XPUB Info

## Get transactions for a given extended public key tracked
## by your Dojo
xpub = 'xpub...'
pd.get_xpub(payload)

Transactions

## Get transactions for a given extended public key or loose address
payload = ('bc1q...', '1Gef...', 'xpub...', 'ypub...', 'zpub...')
pd.get_transactions(payload)

Transaction

## Get transactions info for a txid
transaction = '6d2c2187169c7e85191edeea9d1db732abdefd14c7f1788d999e14b3096f8476'
pd.get_transaction(transaction)

PushTx

## Push a signed transaction to the network using your Dojo node
tx_hex = 'long_hex_string'
pd.push_transaction(tx_hex)

Wallet info

## Request details about a collection of HD accounts and/or 
## loose addresses and/or pubkeys (derived in 3 formats P2PKH, 
## P2WPKH/P2SH, P2WPKH Bech32) including a list of unspent 
## transaction outputs.
payload = ('bc1q...', '1Gef...', 'xpub...', 'ypub...', 'zpub...')
pd.get_wallet(payload)

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

dojo-py-0.0.4.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

dojo_py-0.0.4-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

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