daily pastebin goal
20%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 108 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ## Config
  2.  
  3. ```conf
  4. regtest=1
  5. server=1
  6. daemon=1
  7. txindex=1
  8. discover=0
  9.  
  10. rpcuser=test
  11. rpcpassword=test
  12. rpcallowip=0.0.0.0/0
  13.  
  14. #rpcworkqueue=7000
  15. #rpcthread=8
  16. #rpctimeout=10
  17. ```
  18.  
  19. and start node with `bitcoind`
  20.  
  21. ## Mining
  22.  
  23. mine a block for every 10 seconds
  24.  
  25. ```
  26. while true; do bitcoin-cli -regtest generate 1; sleep 10; done
  27. ```
  28.  
  29. ## Commands
  30.  
  31.  
  32. ```console
  33. $ # Unlike mainnet, in regtest mode only the first 150 blocks pay a reward of 50 bitcoins.
  34. $ # However, a block must have 100 confirmations before that reward can be spent
  35. $ # so we generate 101 blocks to get access to the coinbase transaction from block #1.
  36. $ bitcoin-cli generate 101
  37. [
  38.   "26d4fb4dd449b93ebbda9a36f390d2c7b1dd9557e662840fe61b1f6e3a09d218",
  39.   ....
  40. ]
  41.  
  42. $ # regtest network address version 0x6f
  43. $ bitcoin-cli getaccountaddress ""
  44. mmmSrYNiRQzeiTypt8rF9L3F742PW4ksmL
  45.  
  46. $ # lookup the mining reward
  47. $ bitcoin-cli -regtest getbalance
  48. 50.00000000
  49.  
  50. $ # get new adddress
  51. $ bitcoin-cli getnewaddress
  52. mn41xHRzXuUAAVtujPLLo3Hzbe63GSP117
  53.  
  54. $ # transfer 10 BTC to new address
  55. $ bitcoin-cli sendtoaddress mn41xHRzXuUAAVtujPLLo3Hzbe63GSP117 10
  56. 4deb2fbb98d9029a4e5808b8236d1119ad7315efdfe7406a88c923f5d4b0d5af
  57.  
  58. $ bitcoin-cli generate 1
  59. [
  60.     "4deb2fbb98d9029a4e5808b8236d1119ad7315efdfe7406a88c923f5d4b0d5af"
  61. ]
  62.  
  63. $ # lookup the trx detail
  64. $ bitcoin-cli getrawtransaction 4deb2fbb98d9029a4e5808b8236d1119ad7315efdfe7406a88c923f5d4b0d5af true
  65.  
  66. $ # list received by address
  67. $ bitcoin-cli -regtest listreceivedbyaddress
  68. [
  69.   {
  70.     "address": "mn41xHRzXuUAAVtujPLLo3Hzbe63GSP117",
  71.     "account": "",
  72.     "amount": 10.00000000,
  73.     "confirmations": 1,
  74.     "label": "",
  75.     "txids": [
  76.       "4deb2fbb98d9029a4e5808b8236d1119ad7315efdfe7406a88c923f5d4b0d5af"
  77.     ]
  78.   }
  79. ]
  80. ```
  81.  
  82. ## import key
  83.  
  84. ```console
  85. $ bitcoind help
  86. [...]
  87.   importprivkey <bitcoinprivkey> [label]
  88. ```
  89.  
  90. Private key to WIF
  91. 1 - Take a private key
  92.  
  93. ```
  94.    0C28FCA386C7A227600B2FE50B7CAE_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_11EC86D3BF1FBE471BE89827E19D72AA1D
  95. ```
  96.  
  97. 2 - Add a 0x80 byte in front of it for mainnet addresses or 0xef for testnet addresses. Also add a 0x01 byte at the end if the private key will correspond to a compressed public key
  98. ```
  99.    800C28FCA386C7A227600B2FE50B7C_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_AE11EC86D3BF1FBE471BE89827E19D72AA1D
  100. ```
  101.  
  102. 3 - Perform SHA-256 hash on the extended key
  103. ```
  104.    8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592
  105. ```
  106. 4 - Perform SHA-256 hash on result of SHA-256 hash
  107. ```
  108.    507A5B8DFED0FC6FE8801743720CEDEC06AA5C6FCA72B07C49964492FB98A714
  109. ```
  110. 5 - Take the first 4 bytes of the second SHA-256 hash, this is the checksum
  111. ```
  112.    507A5B8D
  113. ```
  114. 6 - Add the 4 checksum bytes from point 5 at the end of the extended key from point 2
  115. ```
  116.    800C28FCA386C7A227600B2FE50B7CAE11EC8_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_6D3BF1FBE471BE89827E19D72AA1D507A5B8D
  117. ```
  118. 7 - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the Wallet Import Format
  119. ```
  120.    5HueCGU8rMjxEXxiPuD5BDk_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_u4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
  121. ```
  122. WIF to private key
  123. 1 - Take a Wallet Import Format string
  124. ```
  125.    5HueCGU8rMjxEXxiPuD5BDk_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_u4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
  126. ```
  127. 2 - Convert it to a byte string using Base58Check encoding
  128. ```
  129.    800C28FCA386C7A227600B2FE50B7CAE11EC_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_86D3BF1FBE471BE89827E19D72AA1D507A5B8D
  130. ```
  131. 3 - Drop the last 4 checksum bytes from the byte string
  132. ```
  133.    800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
  134. ```
  135. 4 - Drop the first byte (it should be 0x80). If the private key corresponded to a compressed public key, also drop the last byte (it should be 0x01). If it corresponded to a compressed public key, the WIF string will have started with K or L instead of 5 (or c instead of 9 on testnet). This is the private key.
  136. ```
  137.    0C28FCA386C7A227600B2FE50B7CAE1_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_1EC86D3BF1FBE471BE89827E19D72AA1D
  138. ```
  139. WIF checksum checking
  140. 1 - Take the Wallet Import Format string
  141. ```
  142.    5HueCGU8rMjxEXxiPuD5BD_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_ku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ
  143. ```
  144. 2 - Convert it to a byte string using Base58Check encoding
  145. ```
  146.    800C28FCA386C7A227600B2FE50B7CAE11E_SAMPLE_PRIVATE_KEY_DO_NOT_IMPORT_C86D3BF1FBE471BE89827E19D72AA1D507A5B8D
  147. ```
  148. 3 - Drop the last 4 checksum bytes from the byte string
  149. ```
  150.    800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D
  151. ```
  152. 3 - Perform SHA-256 hash on the shortened string
  153. ```
  154.    8147786C4D15106333BF278D71DADAF1079EF2D2440A4DDE37D747DED5403592
  155. ```
  156. 4 - Perform SHA-256 hash on result of SHA-256 hash
  157. ```
  158.    507A5B8DFED0FC6FE8801743720CEDEC06AA5C6FCA72B07C49964492FB98A714
  159. ```
  160. 5 - Take the first 4 bytes of the second SHA-256 hash, this is the checksum
  161. ```
  162.    507A5B8D
  163. ```
  164. 6 - Make sure it is the same, as the last 4 bytes from point 2
  165. ```
  166.    507A5B8D
  167. ```
  168. 7 - If they are, and the byte string from point 2 starts with 0x80 (0xef for testnet addresses), then there is no error.
  169.  
  170. The importing process is now started. Bitcoind will rescan the entire block data to ensure this key has not been used before. This process will take from one to two minutes, depending on your CPU performance. DO NOT abort it before finishing!
  171.  
  172. To avoid rescanning run the following.
  173.  
  174. ```console
  175. $ bitcoind importprivkey 5yourveryveryveryverylongprivatekeystring" "label-here" rescan=false
  176. ```
  177.  
  178. If no errors occurs, the import is a success and Bitcoin-QT users will be able to see the new address in the GUI immediately. If you need to import more keys, just repeat the instructions above. There is currently no command to import a batch of private keys so you will need to wait a minute or two for each key to be imported.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top