Blockchain core

Transaction class

class dposlib.blockchain.tx.Transaction(*args, **kwargs)[source]

A python dict that implements all the necessities to manually generate valid transactions.

datetime

Transaction timestamp returned as python datetime object

feeIncluded

if True then amount + fee = total arktoshi flow

finalize(secret=None, secondSecret=None, fee=None, fee_included=False)[source]

Finalize a transaction by setting fee, signatures and id.

Parameters:
  • secret (str) – passphrase
  • secondSecret (str) – second passphrase
  • fee (int) – manually set fee value in satoshi
  • fee_included (bool) – see Transaction.feeIncluded
identify()[source]

Generate the id field. Transaction have to be signed.

Save public and private keys derived from secrets. This is equivalent to wallet login. it limits number of secret keyboard entries.

Parameters:
  • secret (str) – passphrase
  • secondSecret (str) – second passphrase
multiSignWithKey(privateKey)[source]

Add a signature in signatures field according to given index and privateKey.

Parameters:privateKey (str) – private key as hex string
multiSignWithSecret(secret)[source]

Add a signature in signatures field.

Parameters:
  • index (int) – signature index
  • secret (str) – passphrase
recipient

Receiver address checker and setter

recipientId

Receiver address checker and setter

secondSignature

Second signature

sender

Sender address checker and setter

senderId

Sender address checker and setter

senderPublicKey

Initialize transaction according to senderPublicKey value

static setDynamicFee(value='minFee')

Activate and configure dynamic fees parameters. Value can be either an integer defining the fee multiplier constant or a string defining the fee level to use acccording to the 30-days-average. possible values are avgFee minFee (default) and maxFee.

Parameters:value (str or int) – constant or fee multiplier
setFee(value=None)[source]

Set fee field manually or according to inner parameters.

Parameters:value (int) – fee value in statoshi to set manually
sign()[source]

Generate the signature field. Private key have to be set first. See link().

signSign()[source]

Generate the signSignature field. Transaction have to be signed and second private key have to be set first. See link().

signSignWithKey(secondPrivateKey)[source]

Generate the signSignature field using second private key. It is stored till unlink() is called.

Parameters:secondPrivateKey (str) – second private key as hex string
signSignWithSecondSecret(secondSecret)[source]

Generate the signSignature field using second passphrase. The associated second public and private keys are stored till unlink() is called.

Parameters:secondSecret (str) – second passphrase
signSignature

Second signature

signWithKeys(publicKey, privateKey)[source]

Generate the signature field using public and private keys. They are till unlink() is called.

Parameters:
  • publicKey (str) – public key as hex string
  • privateKey (str) – private key as hex string
signWithSecret(secret)[source]

Generate the signature field using passphrase. The associated public and private keys are stored till unlink() is called.

Parameters:secret (str) – passphrase
timestamp

Transaction timestamp setter

static useDynamicFee(value='minFee')[source]

Activate and configure dynamic fees parameters. Value can be either an integer defining the fee multiplier constant or a string defining the fee level to use acccording to the 30-days-average. possible values are avgFee minFee (default) and maxFee.

Parameters:value (str or int) – constant or fee multiplier

Crypto utils

dposlib.ark.crypto.checkTransaction(tx, secondPublicKey=None, multiPublicKeys=[])[source]

Verify transaction validity.

Parameters:
  • tx (dict or Transaction) – transaction object
  • secondPublicKey (str) – second public key to use if needed
  • multiPublicKeys (list) – owners public keys (sorted according to associated type-4-tx asset)
Returns:

true if transaction is valid

Return type:

bool

dposlib.ark.crypto.getAddress(publicKey, marker=None)[source]

Compute ARK address from publicKey.

Parameters:
  • publicKey (str) – public key
  • marker (int) – network marker (optional)
Returns:

the address

Return type:

str

dposlib.ark.crypto.getAddressFromSecret(secret, marker=None)[source]

Compute ARK address from secret.

Parameters:
  • secret (str) – secret string
  • marker (int) – network marker (optional)
Returns:

the address

Return type:

str

dposlib.ark.crypto.getBytes(tx, **options)[source]

Hash transaction.

Parameters:

tx (dict or Transaction) – transaction object

Keyword Arguments:
 
  • exclude_sig (bool) – exclude signature during tx serialization [defalut: True]
  • exclude_multi_sig (bool) – exclude signatures during tx serialization [defalut: True]
  • exclude_second_sig (bool) – exclude second signatures during tx serialization [defalut: True]
Returns:

bytes sequence

Return type:

bytes

dposlib.ark.crypto.getId(tx)[source]

Generate transaction id.

Parameters:tx (dict or Transaction) – transaction object
Returns:id as hex string
Return type:str
dposlib.ark.crypto.getIdFromBytes(data)[source]

Generate data id.

Parameters:data (bytes) – data as bytes sequence
Returns:id as hex string
Return type:str
dposlib.ark.crypto.getKeys(secret)[source]

Generate keyring containing secp256k1 keys-pair and wallet import format (WIF).

Parameters:secret (str, bytes or int) – anything that could issue a private key on secp256k1 curve
Returns:public, private and WIF keys
Return type:dict
dposlib.ark.crypto.getMultiSignaturePublicKey(minimum, *publicKeys)[source]

Compute ARK multi signature public key according to ARK AIP #18.

Parameters:
  • minimum (int) – minimum signature required
  • publicKeys (list of str) – public key list
Returns:

the multisignature public key

Return type:

str

dposlib.ark.crypto.getSignature(tx, privateKey, **options)[source]

Generate transaction signature using private key.

Parameters:
  • tx (dict or Transaction) – transaction description
  • privateKey (str) – private key as hex string
Keyword Arguments:
 
  • exclude_sig (bool) – exclude signature during tx serialization [defalut: True]
  • exclude_multi_sig (bool) – exclude signatures during tx serialization [defalut: True]
  • exclude_second_sig (bool) – exclude second signatures during tx serialization [defalut: True]
Returns:

signature

Return type:

str

dposlib.ark.crypto.getSignatureFromBytes(data, privateKey)[source]

Generate signature from data using private key.

Parameters:
  • data (bytes) – bytes sequence
  • privateKey (str) – private key as hex string
Returns:

signature as hex string

Return type:

str

dposlib.ark.crypto.getWIF(seed)[source]

Compute WIF address from seed.

Parameters:seed (bytes) – a sha256 sequence bytes
Returns:WIF address
Return type:str
dposlib.ark.crypto.verifySignature(value, publicKey, signature)[source]

Verify signature.

Parameters:
  • value (str) – value as hex string
  • publicKey (str) – public key as hex string
  • signature (str) – signature as hex string
Returns:

true if signature matches the public key

Return type:

bool

dposlib.ark.crypto.verifySignatureFromBytes(data, publicKey, signature)[source]

Verify signature.

Parameters:
  • data (bytes) – data
  • publicKey (str) – public key as hex string
  • signature (str) – signature as hex string
Returns:

true if signature matches the public key

Return type:

bool

dposlib.ark.crypto.wifSignature(tx, wif)[source]

Generate transaction signature using private key.

Parameters:
  • tx (dict or Transaction) – transaction description
  • wif (str) – wif key
Returns:

signature

Return type:

str

dposlib.ark.crypto.wifSignatureFromBytes(data, wif)[source]

Generate signature from data using WIF key.

Parameters:
  • data (bytes) – bytes sequence
  • wif (str) – wif key
Returns:

signature

Return type:

str

Signature utils

Transaction builders

dposlib.ark.v3.transfer(amount, address, vendorField=None, expiration=0)[source]

Build a transfer transaction. Emoji can be included in transaction vendorField using unicode formating.

>>> u"message with sparkles \u2728"
Parameters:
  • amount (float) – transaction amount in ark
  • address (str) – valid recipient address
  • vendorField (str) – vendor field message
  • expiration (float) – time of persistance in hour
Returns:

transaction object

Return type:

dposlib.blockchain.tx.Transaction

dposlib.ark.v3.registerSecondSecret(secondSecret)[source]

Build a second secret registration transaction.

Parameters:secondSecret (str) – passphrase
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.registerSecondPublicKey(secondPublicKey)[source]

Build a second secret registration transaction.

Note

You must own the secret issuing secondPublicKey

Parameters:secondPublicKey (str) – public key as hex string
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.registerAsDelegate(username)[source]

Build a delegate registration transaction.

Parameters:username (str) – delegate username
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.upVote(*usernames)[source]

Build an upvote transaction.

Parameters:usernames (iterable) – delegate usernames as str iterable
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.downVote(*usernames)[source]

Build a downvote transaction.

Parameters:usernames (iterable) – delegate usernames as str iterable
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.registerMultiSignature(minSig, *publicKeys)[source]

Build a multisignature registration transaction.

Parameters:
  • minSig (int) – minimum signature required
  • publicKeys (list of str) – public key list
Returns:

transaction object

Return type:

dposlib.blockchain.tx.Transaction

dposlib.ark.v3.registerIpfs(ipfs)[source]

Build an IPFS registration transaction.

Parameters:ipfs (str) – ipfs DAG
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.multiPayment(*pairs, **kwargs)[source]

Build multi-payment transaction. Emoji can be included in transaction vendorField using unicode formating.

>>> u"message with sparkles \u2728"
Parameters:
  • pairs (iterable) – recipient-amount pair iterable
  • vendorField (str) – vendor field message
Returns:

transaction object

Return type:

dposlib.blockchain.tx.Transaction

dposlib.ark.v3.delegateResignation()[source]

Build a delegate resignation transaction.

Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.htlcSecret(secret)[source]

Compute an HTLC secret hex string from passphrase.

Parameters:secret (str) – passphrase
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction
dposlib.ark.v3.htlcLock(amount, address, secret, expiration=24, vendorField=None)[source]

Build an HTLC lock transaction. Emoji can be included in transaction vendorField using unicode formating.

>>> u"message with sparkles \u2728"
Parameters:
  • amount (float) – transaction amount in ark
  • address (str) – valid recipient address
  • secret (str) – lock passphrase
  • expiration (float) – transaction validity in hour
  • vendorField (str) – vendor field message
Returns:

transaction object

Return type:

dposlib.blockchain.tx.Transaction

dposlib.ark.v3.htlcClaim(txid, secret)[source]

Build an HTLC claim transaction.

Parameters:
  • txid (str) – htlc lock transaction id
  • secret (str) – passphrase used by htlc lock transaction
Returns:

transaction object

Return type:

dposlib.blockchain.tx.Transaction

dposlib.ark.v3.htlcRefund(txid)[source]

Build an HTLC refund transaction.

Parameters:txid (str) – htlc lock transaction id
Returns:transaction object
Return type:dposlib.blockchain.tx.Transaction

API

class dposlib.ark.v2.api.Block(blk_id, **kw)[source]
class dposlib.ark.v2.api.Delegate(username, **kw)[source]
class dposlib.ark.v2.api.Wallet(address, **kw)[source]
class dposlib.ark.v2.api.Webhook(whk_id, **kw)[source]