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[subaccount][, return_pointer][, confidential])
Generate and return P2SH hash the user can pay to. This call is limited to 1000 P2SH per day for each wallet.
Check usage on Github: JS Example or look at our Python example

  • 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)

hex encoded script

Return type:


Returns a P2SH hash the anyone can pay to given receiving_id.
Check usage on Github: JS Example
Parameters:receiving_id (String) – The GreenAddress’ user receiving ID
Returns:base58 encoded P2SH address
Return type:String
Returns next unused EXTERNAL branch private key pointer.
Check usage on Github: JS Example
Parameters:subaccount (Number) – If not specified, default subaccount is Main.
com.greenaddress.vault.prepare_payreq(value, data[, priv_data])
Prepare BIP70 payment protocol transaction.
Check usage on Github: JS Example
  • Number (value) – satoshis
  • data – data returned from process_bip0070_url

same as prepare_tx

com.greenaddress.vault.prepare_redeposit(txouts[, priv_data])
Prepare nLockTime redeposit.
Check usage on Github: JS Example
Reference guide:
Parameters:Array (txouts) – [[txhash, out_n], ...]
Returns:same as prepare_tx
com.greenaddress.vault.prepare_sweep_social(pubkey[, use_electrum][, subaccount])
Prepare public key sweeping transaction.
Check usage on Github: JS Example
  • pubkey (Array) – pubkey bytes
  • use_electrum (Boolean) – whether to use Electrum servers to get the balance. If false, only GreenAddress transactions are considered.

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

com.greenaddress.vault.prepare_tx(value, rcpt_ad, add_fee, priv_data)
  • value (String) – satoshis as string.
  • rcpt_ad (String) – recipient address.
  • add_fee (String) – ‘sender’ or ‘recipient’ pays the fee
  • priv_data – external private transaction and other additional data {external_private: Boolean, pointer: Number, pubkey: bytes array, social_destination: String, instant: Boolean, memo: String, minimize_inputs: Boolean}
  • priv_data.minimize_inputs – whether to optimize for minimum number of inputs instead of nLockTime expiring

prep_info dictionary

    'tx': hexencoded binary unsigned transaction without signatures in redeem scripts,
    'prev_outputs': [
            'script': hex,
            'value': satoshis,
            'branch': branch of users' pubkey in the redeem script,
            'pointer': pointer in the branch,
            'subaccount': Number
    'change_pointer': Number,
    'requires_2factor': Boolean

The ‘tx’ returned contains the original unhashed prev_output script in its redeem script for each input. This original script can be used to generate the P2SH output script at the js side. This P2SH prev output script is needed to generate a signature.

Returns BIP70 payment request data
Check usage on Github: JS Example
Parameters:String (url) – payment request URL
Returns:{ ‘outputs’: [{‘amount’: satoshis, ‘address’: String}, ...], ‘merchant_data’: hex, ‘payment_url’: String, ‘payreq_url’: String, ‘payreq’: hex, ‘memo’: String, ‘requires_instant’: Boolean}
  • requires_instant field is deprecated, and BIP70 instant payments extension is still pending finalisation.
com.greenaddress.vault.send_raw_tx(rawtx_hex[, twofac_data][, priv_data])
Sign and send a hex-encoded transaction.
  • 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
    For raw tx ‘bumping fee’:
    - bump_fee_amount - satoshi amount of bumped fee
  • priv_data (dict) –

    optional additional transaction data - keys:

    - instant: boolean
    - memo: string

dict - keys:

txhash: resulting tx hash
[limit_decrease]: optional amount of spending limit decrease

com.greenaddress.vault.send_reddit(recipient, href)
Vouchers: Send a reddit message containing private derived key.
Check usage on Github: JS Example
  • recipient (String) – recipient username
  • href (String) – private key /redeem/ URL
com.greenaddress.vault.send_tx(signatures[, twofac_data])
The transaction must have been prepared using prepare_tx and signed client side.
Check usage on Github: JS Example
  • signatures (Array) – list of hex-encoded user signatures in the same order as prev_outputs.
  • twofac_data – (code requested with action=’send_tx’) {method: ‘gauth’|’email’|’sms’|’phone’, code: String}

hex encoded txhash.

Return type:


com.greenaddress.vault.set_scanning_key(subaccount, pointer, pubkey)