Skip to content

SPV RPC Calls

Peter John Bushnell edited this page Apr 1, 2021 · 16 revisions

spv_claimhtlc
spv_createanchor
spv_createanchortemplate
spv_createhtlc
spv_decodehtlcscript
spv_dumpprivkey
spv_estimateanchorcost
spv_getaddresspubkey
spv_getbalance
spv_gethtlcseed
spv_getnewaddress
spv_getrawtransaction
spv_gettxconfirmations
spv_listanchors
spv_listanchorauths
spv_listanchorrewardconfirms
spv_listanchorrewards
spv_listanchorsunrewarded
spv_listanchorspending
spv_listhtlcoutputs
spv_listtransactions
spv_refundhtlc
spv_rescan
spv_sendrawtx
spv_sendtoaddress
spv_syncstatus

spv_claimhtlc

Claims all coins in HTLC address

Arguments  
scriptaddress             string    HTLC address  
destinationaddress        string    Destination for funds in the HTLC  
seed                      string    Seed that was used to generate the hash in the HTLC  
feerate                   number    Feerate (satoshis) per KB (Default: 10000)  

Results  
{  
    txid                  string    The transaction id  
    sendmessage           string    Send message result  
}  

spv_createanchor

Creates (and optional submits to bitcoin blockchain) an anchor tx with latest possible (every 15th) authorized blockhash. The first argument is the specific UTXOs to spend.

Arguments  
inputs                    JSON array of objects containing  
    txid                  string    The transaction id of the bitcoin UTXO to spend  
    vout                  number    The output index to spend in UTXO  
    amount                number    Amount of output in satoshis  
    privkey               string    WIF private key of bitcoin for signing this output  
rewardAddress             string    User's P2PKH address (in DeFi chain) for reward  
send                      bool      Send it to btc network (Default = true)  
feerate                   number    Feerate (satoshis) per 1000 bytes (Default = 1000)  

Results  
txHex                     string    The hex-encoded raw transaction with signature(s)  
txHash                    string    The hex-encoded transaction hash  

spv_createanchortemplate

Creates an anchor tx template with latest possible (every 15th) authorized blockhash.

Argument  
rewardAddress             string    User's P2PKH address (in DeFi chain) for reward  

Result  
txHex                     string    The hex-encoded raw transaction with signature(s)  

spv_createhtlc

Creates a Bitcoin address whose funds can be unlocked with a seed or as a refund.
It returns a json object with the address and redeemScript.

Arguments  
seller_key                string    The public key of the possessor of the seed  
refund_key                string    The public key of the recipient of the refund  
hash                      string    SHA256 hash of the seed  
timeout                   string    Timeout of the contract (denominated in blocks) relative to its placement in the blockchain  

Results  
{  
    address               string    The value of the new Bitcoin address.  
    redeemscript          string    The string value of the hex-encoded redemption script  
}  

spv_decodehtlcscript

Decode and return value in a HTLC redeemscript

Argument  
redeemscript              string    The HTLC redeemscript  

Results  
{  
    sellerkey             string    Seller public key  
    buyerkey              string    Buyer public key  
    blocks                number    Locktime in number of blocks  
    hash                  string    Hash of the seed  
}  

spv_dumpprivkey

Reveals the private key corresponding to 'address'

Argument  
address                   string    The BTC address for the private key  

Result  
key                       string    The private key  

spv_estimateanchorcost

Estimates current anchor cost with default fee, one input and one change output.

Argument
feerate                   number    Feerate (satoshis) per 1000 bytes (Default = 1000)

Result
cost                      number    Estimated anchor cost (satoshis)

spv_getaddresspubkey

Return raw pubkey for Bitcoin address if in SPV wallet

Argument
address                   string    Bitcoin address

Result
pubkey                    string    Raw pubkey hex

spv_getbalance

Returns the Bitcoin balance of the SPV wallet

Result
amount                    number    The total amount in BTC received in the SPV wallet

spv_gethtlcseed

Returns the HTLC secret if available

Argument
address                   string    HTLC address

Result
secret                    string    Returns HTLC seed

spv_getnewaddress

Creates and adds a Bitcoin address to the SPV wallet

Result
address                   string    Returns a new Bitcoin address

spv_getrawtransaction

Return the raw transaction data

Argument
txid                      string    The transaction id

Result
data                      string    The serialized, hex-encoded data for 'txid'

spv_gettxconfirmations

Reports tx confirmations (if any)...

Argument
txhash                    string    Hash of tx to look for

Result
count                     number    Tx confirmations. Zero if not confirmed yet (mempooled?) and -1 if not found