/docs/wallet.md

https://gitlab.com/jslee1/api-v1-client-python · Markdown · 155 lines · 119 code · 36 blank · 0 comment · 0 complexity · f036ef59f5465acb1aa24bb5369ef6c7 MD5 · raw file

  1. ##`wallet` module
  2. An instance of the `Wallet` class needs to be initialized before it can be used.
  3. Constructor params:
  4. ```
  5. identifier : str
  6. password : str
  7. service_url : str - URL to an instance of service-my-wallet-v3 (with trailing slash)
  8. second_password : str (optional)
  9. api_code : str (optional)
  10. ```
  11. Usage:
  12. ```python
  13. from blockchain.wallet import Wallet
  14. wallet = Wallet('ada4e4b6-3c9f-11e4-baad-164230d1df67', 'password123', 'http://localhost:3000')
  15. ```
  16. ####`send`
  17. Send bitcoin from your wallet to a single address. Returns a `PaymentResponse` object.
  18. Params:
  19. ```
  20. to : str - receiving address
  21. amount : int - amount to send (in satoshi)
  22. from_address : str - specific address to send from (optional)
  23. fee : int - transaction fee in satoshi. Must be greater than default (optional)
  24. note : str - public note to include with the transaction if amount >= 0.005 BTC (optional)
  25. ```
  26. Usage:
  27. ```python
  28. payment = wallet.send('1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob', 1000000, from_address='1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq')
  29. print payment.tx_hash
  30. ```
  31. ####`send_many`
  32. Send bitcoin from your wallet to multiple addresses. Returns a `PaymentResponse` object.
  33. Params:
  34. ```
  35. recipients : dictionary - dictionary with the structure of 'address':amount
  36. from_address : str - specific address to send from (optional)
  37. fee : int - transaction fee in satoshi. Must be greater than default (optional)
  38. note : str - public note to include with the transaction if amount >= 0.005 BTC (optional)
  39. ```
  40. Usage:
  41. ```python
  42. recipients = { '1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob' : 1428300,
  43. '1A8JiWcwvpY7tAopUkSnGuEYHmzGYfZPiq' : 234522117 }
  44. payment = wallet.send_many(recipients)
  45. print payment.tx_hash
  46. ```
  47. ####`get_balance`
  48. Fetch the wallet balance. Includes unconfirmed transactions and possibly double spends. Returns the wallet balance in satoshi.
  49. Usage:
  50. ```python
  51. print wallet.get_balance()
  52. ```
  53. ####`list_addresses`
  54. List all active addresses in the wallet. Returns an array of `Address` objects.
  55. Params:
  56. ```
  57. confirmations : int - minimum number of confirmations transactions must have before being included in balance of addresses (optional)
  58. ```
  59. Usage:
  60. ```python
  61. addresses = wallet.list_addresses()
  62. for a in addresses:
  63. print a.balance
  64. ```
  65. ####`get_address`
  66. Retrieve an address from the wallet. Returns an `Address` object.
  67. Params:
  68. ```
  69. confirmations : int - minimum number of confirmations transactions must have before being included in the balance (optional)
  70. ```
  71. Usage:
  72. ```python
  73. addr = wallet.get_address('1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob', confirmations = 2)
  74. print addr.balance
  75. ```
  76. ####`new_address`
  77. Generate a new address and add it to the wallet. Returns an `Address` object.
  78. Params:
  79. ```
  80. label : str - label to attach to the address (optional)
  81. ```
  82. Usage:
  83. ```python
  84. newaddr = wallet.new_address('test_label')
  85. ```
  86. ####`archive_address`
  87. Archive an address. Returns a string representation of the archived address.
  88. Params:
  89. ```
  90. address : str - address to archive
  91. ```
  92. Usage:
  93. ```python
  94. wallet.archive_address('1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob')
  95. ```
  96. ####`unarchive_address`
  97. Unarchive an address. Returns a string representation of the unarchived address.
  98. Params:
  99. ```
  100. address : str - address to unarchive
  101. ```
  102. Usage:
  103. ```python
  104. wallet.unarchive_address('1NAF7GbdyRg3miHNrw2bGxrd63tfMEmJob')
  105. ```
  106. ###Response object field definitions
  107. ####`PaymentResponse`
  108. ```
  109. message : str
  110. tx_hash : str
  111. notice : str
  112. ```
  113. ####`Address`
  114. ```
  115. balance : long
  116. address : str
  117. label : str
  118. total_received : long
  119. ```