vault module

On GreenAddress API, vault is the primary module for funds handling. Here you can “generate” new P2SH, the BIP32 “bitcoin addresses”, but also sign and transmit outgoing transactions.

Social transactions are supported too by GreenAddress API, and the BIP0070 payment protocol as well.

com.greenaddress.vault

com.greenaddress.vault.broadcast_raw_tx(rawtx_hex)
Broadcasts a hex-encoded fully signed transaction.
Parameters:rawtx_hex (hexstring) – Raw hex representation of the transaction to broadcast.
Returns:transaction hash hex
Return type:String
com.greenaddress.vault.fund([subaccount][, return_pointer][, addr_type][, confidential])
Generate and return hex encoded script the user can pay to. This call is limited to 1000 per day for each wallet.
Check usage on Github: Python Example

References:
Parameters:
  • subaccount (Int) – If not specified default is main account.
  • return_pointer (boolean) – Whether to return BIP32 pointer number in addition to the script (default=false)
  • addr_type (String) – The type of addresses desired, p2sh, p2wsh or csv.
  • confidential (bool) – Deprecated - must be False
Returns:

hex encoded script if return_pointer is False or

{
    'branch': Number,
    'subaccount': Number,
    'pointer': Number,
    'script': String,
    'addr_type': String
}
com.greenaddress.vault.fund_receiving_id(receiving_id)
Return a P2SH hash that anyone can pay to given receiving_id.
Parameters:receiving_id (String) – The GreenAddress’ user receiving ID
Returns:base58 encoded P2SH address
Return type:String
com.greenaddress.vault.get_next_private_derived_pointer([subaccount])
Return next unused EXTERNAL branch private key pointer.
Parameters:subaccount (Number) – If not specified, default subaccount is Main.
com.greenaddress.vault.get_utxos_for_script_hash(scriptpubkeyhash)
Returns a list of unspent outputs for a given scriptPubKey hash, including any unconfirmed mempool transactions
Parameters:scriptpubkeyhash (hexstring) – Raw hex representation of the script pub key sha256 hash
Returns:[{‘height’: int, ‘tx_pos’: int, ‘tx_hash’: hexstring, ‘value’: number}]
com.greenaddress.vault.prepare_payreq(value, data[, priv_data])
Deprecated, this call will be removed in the near future.
Users should construct complete transactions client side and
sign/send them using sign_raw_tx/send_raw_tx.
com.greenaddress.vault.prepare_redeposit(txouts[, priv_data])
Deprecated, this call will be removed in the near future.
Users should construct complete transactions client side and
sign/send them using sign_raw_tx/send_raw_tx.
com.greenaddress.vault.prepare_sweep_social(pubkey[, use_electrum][, subaccount])
Prepare public key sweeping transaction.
Parameters:
  • pubkey (Array) – pubkey bytes
  • use_electrum (Boolean) – whether to use Electrum servers to get the balance. If false, only GreenAddress transactions are considered.
Returns:

{‘tx’: hex, ‘prevout_scripts’: [hex, ...]}

com.greenaddress.vault.prepare_tx(value, rcpt_ad, add_fee, priv_data)
Deprecated, this call will be removed in the near future.
Users should construct complete transactions client side and
sign/send them using sign_raw_tx/send_raw_tx.
com.greenaddress.vault.process_bip0070_url(url)
Deprecated, this call will be removed in the near future.
Users should construct complete transactions client side and
sign/send them using sign_raw_tx/send_raw_tx.
com.greenaddress.vault.send_raw_tx(rawtx_hex[, twofac_data][, priv_data][, return_tx])
Sign and send a hex-encoded transaction.
Parameters:
  • rawtx_hex (hexstring) – Raw hex representation of the transaction to sign and send.
  • twofac_data (dict) –

    optional 2FA data - keys:

    For all transactions – 2FA must be requested with action ‘send_raw_tx’ (for most cases), or ‘bump_fee’:
    - code
    - method
    For raw tx ‘simply spending’ some given amount of satoshi:
    - send_raw_tx_amount - spent satoshi amount (including fee)
    - send_raw_tx_fee - fee satoshi amount
    - send_raw_tx_recipient - recipient address
    - send_raw_tx_change_idx - change output index (-1 if no change)
    For raw tx ‘bumping fee’:
    - bump_fee_amount - satoshi amount of bumped fee
    For raw tx ‘simply spending’ some given amount of satoshi, below user’s spending limit (not requiring 2FA):
    - try_under_limits_spend - dict with keys amount (can be ‘any’), change_idx, fee (optional)
    For raw tx ‘bumping fee’, below user’s spending limit (not requiring 2FA):
    - try_under_limits_bump - satoshi amount of bumped fee
  • priv_data (dict) –

    optional additional transaction data - keys:

    - instant: boolean
    - payreq: hex encoded payment request for BIP 70 payments
    - memo: string, will override the memo from ‘payreq’ if present
  • boolean (return_tx) – True if the signed tx should be returned
Returns:

dict - keys:

txhash: resulting tx hash
tx: hex encoded resulting tx, only returned if return_tx is true
[new_limit]: optional amount of new spending limit after the transaction

com.greenaddress.vault.send_tx(signatures[, twofac_data])
Deprecated, this call will be removed in the near future.
Users should construct complete transactions client side and
sign/send them using sign_raw_tx/send_raw_tx.
com.greenaddress.vault.set_scanning_key(subaccount, pointer, pubkey)
com.greenaddress.vault.sign_alt_tx(rawtx_hex, txtype, inputs[, twofac_data][, fork_id])
Sign a hex-encoded altcoin transaction.
The transactions input scripts must have a placeholder
PUSH 00 (0x01 0x00) which will be replaced with a push of the
GreenAddress signature. The inner script for each input should
be passed in the inputs parameter along with the GreenAddress
derivation information, i.e. the subaccount the input is from and
the pointer that it represents (this information can be fetched
from e.g. addressbook.get_my_addresses).
Parameters:
  • rawtx_hex (hexstring) – Raw hex representation of the transaction to sign.
  • Array (inputs) – [{‘script’:...,’subaccount’:...,’pointer’:...,’value’:...}, ...]
  • txtype (string) – The type of altcoin transaction. Currently must be “bcash” or “forkid”.
  • twofac_data (dict) – 2FA data for the action ‘sign_alt_tx’, if 2FA is enabled.
  • fork_id (int) – The preimage fork id to use when signing “forkid” transactions, pre-multiplied by 256 and not having any of the first 8 bits set.
Returns:

dict - keys:

sha256d: Double SHA256 of the transactions binary data
hashes: Transaction signature hashes for each input
scripts: Script including the GreenAddress signature for each input
signatures: The GreenAddress signatures for each input

com.greenaddress.vault.sign_raw_tx(rawtx_hex[, twofac_data])
Sign a hex-encoded transaction.
Parameters:
  • rawtx_hex (hexstring) – Raw hex representation of the transaction to sign.
  • twofac_data (dict) – optional 2FA data - keys are the same as for the send_raw_tx RPC.
Returns:

dict - keys:

tx: resulting signed tx
[new_limit]: optional amount of new spending limit after the transaction