Handling incoming instant confirmation

GreenAddress’ instant confirmations speed up Bitcoin transactions, introducing a trusted third-party for multisigned transactions certifying that the transactions won’t be double spent.


Here we show the different ways of handling instant confirmation transactions from GreenAddress.

GreenAddress services are designed to reduce friction against Bitcoin and instant confirmations. As the official documentation explains, the classic Bitcoin client will show a transaction as “n/unconfirmed” until the transaction is 6 blocks deep.

The way GreenAddress works with multisignature makes the service able to emit instant transactions. In GreenAddress, transactions are signed by two parties, and GreenAddress will not allow for double spends when providing the instant confirmation.

This means that GreenAddress transactions, if you trust the service, can be identified as “double spend free”, and marked as instant. The choice, as almost everything in GreenAddress, is in the hand of the user.

Using BIP70 instant confirmation extension

If you already implement BIP70 then implementing this extension is quite easy.

The proposal is available on Github.

An example will be available soon.

Using the GreenAddress WAMP server to verify instant transactions

After a watch-only or full access login, users can call the txs/get_list_v2 method to fetch the transactions history. Using it without any parameter will return the list of last 30 transactions.:

def getTransactions(self, page='', s_query='', sort_by='', date_range='', subacc=''):
    d = self.call('gait:txs/get_list_v2', page, s_query, sort_by, date_range, subacc)

WAMP’s APIs are asynchronous. This means you should bind a chain of callbacks to handle the result. Here we assume a predefined and very simple print callback:

def callback(data):
    print data

The result will be printed on stdout. We’re going to look at the array ‘list’, containing the transactions’ details and endpoints. This is how a single transaction could appear:

    u'cur_block': 278586,
    u'fiat_value': 478.58,
    u'fiat_currency': u'USD',
    u'list': [{
    u'instant': True,
    u'memo': u"an instant transaction",
    u'eps': [{}, ... ], # Transaction's endpoints are skipped here for readability
    u'block_height': None,
    u'txhash': u'd6a6fd117a7b84e6a9a6ae7f2aa46ecdfdd440d13dc2058d83ce7fad9731'

Using the GreenAddress HTTP API to verify instant transactions

This code is extracted from the GreenAddress instant verify plugin for Electrum Bitcoin client, and shows how a third-party service could check GreenAddress instant confirmations without having an account at GreenAddress.

The plugin is available on Github.

The example uses the ability of Electrum client to sign messages with its own private key, and so certify the ownership of a Bitcoin address, without exposing the private keys or doing any transactions.

addr = self.get_my_addr(tx)
message = "Please verify if %s is GreenAddress instant confirmed" % tx.hash()
sig = self.wallet.sign_message(addr, message, password)

conn = httplib.HTTPSConnection('greenaddress.it')
conn.request("GET", ("/verify/?signature=%s&txhash=%s" % (urllib.quote(sig), tx.hash())),
    None, {'User-Agent': 'Electrum'})
response = conn.getresponse()
response = json.loads(response.read())

The steps are simple and self-explanatory: the script finds some address which received a GreenAddress instant transaction, then uses its private key to sign a message, containing the transaction hash, and sends the signature with an HTTP query to the GreenAddress server.

The API answer is a JSON dictionary, with a ‘verified’ key which will have a true value if verification is positive.

if response.get('verified'):
    print '%s is covered by GreenAddress instant confirmation' % tx.hash()
    print '%s is not covered by GreenAddress instant confirmation' % tx.hash()

The consideration of this practice is that to sign a message with your own private keys, you need to use them. This requirement is there for privacy reasons, to avoid exposing information about GreenAddress.