2

Tell me how to interact with https://www.blockchain.com/. 1). I need to withdraw all transactions from the address, my code outputs transactions only for the last day? 2). How do I add additional transaction information (Sigscript, Witness)?

#!/usr/bin/env python
import bitcoin, sys

if len(sys.argv) < 2:
    ADDRESS = "1NDyJtNTjmwk5xPNhjgAMu4HDHigtobu1s"
elif len(sys.argv) < 3:
    ADDRESS = sys.argv[1]
else:
    print('Wallet address must be provided.')

def main():
    #bitcoin.allTransactions(ADDRESS)
    bitcoin.simpleTransactions(ADDRESS)
    
if __name__ == '__main__':
    main()

1 Answer 1

3

As the API documentation specifies, the response of /rawaddr/$address will only return up to 50 transactions. There is an optional parameter &offset=n which let's you skip the first n transactions. The first call, you get fifty transactions. Then you add the parameter offset=50 to skip the first fifty transactions in the response to the second call. This will result in you retrieving the second fifty transactions (51-100). Increment the offset each time by 50, until you have collected all transactions for the address. Quoting from the documentation:

Single Address

  • https://blockchain.info/rawaddr/$bitcoin_address
  • Address can be base58 or hash160
  • Optional limit parameter to show n transactions e.g. &limit=50 (Default: 50, Max: 50)
  • Optional offset parameter to skip the first n transactions e.g. &offset=100 (Page 2 for limit 50)

After you have collected all txids, you look up the details of each transaction with rawtx/$txid:

Single Transaction

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.