Call Bitcoin RPC


> ![](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/169726/3bde7778-917f-d068-79e7-2d757ae8d396.jpeg)

详细使用请看视频—— [Bitcoin 调用 rpc 查询区块地址](https://www.bilibili.com/video/av41352137/)

### 配置文件
Mac 系统下 默认配置文件文件在 ` ~/Library/Application\ Support/Bitcoin`

放在 /mnt/bitcoin 目录下

```
# /mnt/bitcoin/bitcoin.conf

server=1
daemon=1
rpcallowip=127.0.0.1/0 #局域网访问
rpcthreads=10
txindex=1
rpcuser=user #用户
rpcpassword=pass #密码

[regtest] #从 0.17.0开始，在一个配置文件中设置不同的启动模式
rpcport=18443
deprecatedrpc=signrawtransaction # 从 0.17.0版本signrawtransaction 要被弃用
```

### 运行节点

`
bitcoind -datadir=/mnt/bitcoin # 确保有/mnt/bitcoin/bitcoin.conf
`

```
# 运行regtest模式，即私链模式
bitcoind -regtest -datadir=/mnt/bitcoin

# 私链持续挖矿
while true; do bitcoin-cli -regtest -datadir=/mnt/bitcoin generate 1; sleep 1; done
```

### curl getblockcount

```
curl -X POST http://127.0.0.1:8332/ -u user:pass -H 'content-type:text/plain;' \
-d '{"jsonrpc":"2.0","id":"1","method":"getblockcount","params":[]}'

{
    "result":238667,
    "error":null,
    "id":"1"
}
```

### curl getblockhash

**如果没有配置 rpcuser、rpcpassword，curl 不会返回数据**

```
curl -X POST http://127.0.0.1:8332/ -u user:pass -H 'content-type:text/plain;'  \
-d '{"jsonrpc":"1.0","id":"1","method":"getblockhash","params":[0]}'

{
  "result": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
  "error": null,
  "id": "1"
}
```

### curl getblock

```
curl -X POST http://127.0.0.1:8332/ -u user:pass -H 'content-type:text/plain;'  \
-d '{"jsonrpc":"1.0","id":"1","method":"getblockhash","params":["000000000000000007fdf66aea8c0d09782403aa23af192319e2771da0059c5d"]}'

￼
{
  "hash": "000000000000000000cf4e3996f80a40da1942dfe0a7e35463ae909ec3624590",
  "confirmations": 590,
  "height": 372500,
  "version": 3,
  "versionHex": "00000003",
  "merkleroot": "42fc9becdce3b2ab130c8aa9a8db9a10285d0bd55d071b4da0d82559633433a8",
  "time": 1441103216,
  "mediantime": 1441101153,
  "nonce": 2207378512,
  "bits": "181443c4",
  "difficulty": 54256630327.88996,
  "chainwork": "00000000000000000000000000000000000000000009c3fea4dfcf87f775a593",
  "nTx": 1519,
  "previousblockhash": "00000000000000000d58f5cf805563e7157b276d2a99d70a331d50fc4fcadb58",
  "nextblockhash": "000000000000000001c8843febd9694ef46f1d77a688c715e38d7b81a1e0cab8",
  "strippedsize": 816226,
  "size": 816226,
  "weight": 3264904,
  "tx": [
    "3ca0dfea67a22627ef41f3009cf6f5e2caabbbe659e4e8bc6b50c0354b381617",
    "bf3aed15986e75506339cbd91dc195ce6ed1654ef58603b89f3a32da772261f3",
    "62eb3d9e40873f1a7c9f5212929d7784984b460a8acf97914170b560aceaf4f5"
  ]
}
```

### curl getrawtransaction

```
curl -X POST http://127.0.0.1:8332/ -u user:pass -H 'content-type:text/plain;'  \
-d '{"jsonrpc":"1.0","id":"1","method":"getrawtransaction","params":["62eb3d9e40873f1a7c9f5212929d7784984b460a8acf97914170b560aceaf4f5"]}'

{
  "result": "010000000d96387c7b65d47a1cc9685fb4e14349e6202e2f5424c454241c66214162e73963010000006b483045022100fd515538fa0c24aed7bd3f9a0a7d4c3986a47f4790c9ff535cae365b923bf7b2022015df2122618d86afda9444cfceffd5357f933e73c0b310b6542074c4a40b8e3f012102372801dfabd914cb3f313a9a6732af986ca037fe085a7fa8e5395dc270e43341ffffffff96387c7b65d47a1cc9685fb4e14349e6202e2f5424c454241c66214162e739630e0000006b483045022100c5bb04c7a02f2942ae2d2df8eb74b011803b3ddc998033bc2d96febcaf9914e002206800e0941d1211a14881d9b3ac948329cd4e0d4178ada50a05b4d564c8a92940012102e12d207bb38491afb9f5b9813936287448ce22ddd29162c0e9c9acbf012c9911ffffffff4f713df21e8a88c2c7d4ed3827ed47b7558d0c6b061b93258c64b49a498f099e040000006b4830450221008f7f4e724c65e34beff1626a6258353cbe4b00e19d3ccddb2cad8ab496719bfa0220406fc719fe2d50db174ab862416e7fda59134db016604e83885539a63f8d8d8a012103763678ff1a57286a63ef649c8819eea06d850fe69bc1b8e76de824e17d9c4e44ffffffff6638e73fc2d22d683dfb8771f64e04564c9cfebe0b9fd4a95ca9620e3380851e130000006b483045022100f8a218918126bb317999936cf181c5354a37139e006f9e99086bd0aa43a8a8d10220599fd4fe697df8332e0870377c22f79dee5b2e22cca0b269d48c6216844c21160121036058456f982a31e5ae85b33d10c73f973fa04dcda5bef203053764c66c1987f5ffffffff590b2a2df25fd67ba86d3b997646b59388fffaffcb380d1532bf18b3b4d1f13a000000006b483045022100bb83b1f198ca579b687a74fab118c47a5da74c03b2eff250fa9cf8364a8aa6e80220114f36ff5cac8f82ab04d8f992325625f79b6131aaf5e95a63a7294e0c18aa4301210349f729cb92967f56857c173f32c00ce11d8b1695cecd70930e234f6c450aa805ffffffff96387c7b65d47a1cc9685fb4e14349e6202e2f5424c454241c66214162e739630c0000006b4830450221009b907423f565d61d74008820aebf3a810d4adc39206c52a74936c2ab26df2e7002201f381a38754394257cfc7c109a6fa68cb58f1b2b4d90d60fe5e348162b907052012102aed673e7e11a16837eb90334952a5a8e6c1c8cf0f79221687fae1e933f53e51cffffffffa892eb064792d8092211e988364c758d049891ebceac869e7cf7908fc8536d60000000006b4830450221009998a86a7d6819ad5ad54b02616aba1c08651b7a856a078808fffd683840bb1402204b5e351faa402a43d630aa4ac6396e2025275725f207117552c7b27839f0913d012103fad4d5612d89be07d4bc228f1a17b3268ba61810dd9311cbc2ea7264ca5431d2ffffffff7ac8babe4fe18c018cd4e437ece12fef65897015a51d98e3b0e3072420a487af000000006b48304502210081a93055cd07a21cd6959e6f6529b27a51adf70c2f8bf47005406a9417426cf8022014c75eb48b4303a61dc931132eee57aa877e6ba50bb9d3da0f3ccb0b09d7d68a0121023a83a94ec2e9f82d822bd7fbc97a884d905af7173c99845424d0a7416c4cdc50ffffffffb65fe968162638020618b36b0a6b9f9b727c021d18b552005b043245cee101dd0f0000006b483045022100bb21987e7a2587752329fedc665745e266d1163038f26028795b751407fbd5a1022003086167ef646126b026d309e6ea7285e07dfbd0f0e63bcc99222f4432edd95901210261508e81863e3da237935f0cbc14449a5c932bf616955171e562c10b0e2227dcffffffff96387c7b65d47a1cc9685fb4e14349e6202e2f5424c454241c66214162e73963100000006a47304402207b28a0e3972db06658568d68bbe658d215d1aade783b63cb06e53ed5dfa552c40220069054745a87f666e9dbf9037c463a3e6db6bf52654e53651a0be8811aca69450121021969a96c51157aa4d606b93ceedc5d539961ffc54edb1fd0e562c45eb6f3f8a3ffffffffde16e39cb94af47b68a2de8bca1c4c129ea822a6c203df7b041de7e7d177e8d3130000006a4730440220591a4f57c3b9cd7e980f94157dc53eee2505169cf67a970d74bf5687d8afb474022049be8389b836dc448a5f748273cf4c8417426be5d4bcadd46f4038c208b740ab0121035428cb8056f3e52221a0736588c0c72f5ace90e86855342f673610f8b5604a40ffffffff7a91e8aef7704f9097c651b72da1597e81b71b8a84fcb3dde27ee8a6e210ed670e0000006a47304402205c76cd5810cac4f119cf0b40ceee5005bbb4b877bf7cd5de87c293867752a32702207142269cfe87c1a89cac2159c86adb4f3a21812d0049eaa78245ccb5976fce340121029e9aad07f57a8ca071e7dc754920393b60fb0a7d8e549ded24be31f9e788de67ffffffff0a01526ddea3bdb0d9016b1ac471e219c1c3056bc085f5a99c392e840449378b000000006a47304402202fdee85d0ba26045d3f367ed035a4794c6f0b0cb6da0093e56e711e62e4e711c0220231e78b6c63043420162a3fe299cd4d60b44329a9193ce035d70e1370456c36b0121039dc0fbb2f2f4f03a51467bdc10ef513c919959bd56a668f3a412db6e03b4bc23ffffffff0851ea5a00000000001976a914bae698c673a97da3e0c3e0d3769332aa03e5142088ace10f71ef000000001976a9142abe97e47fc446f49c65631225fd0db636d793b688acb1c89e70000000001976a914eb19735b3857504d17ee3e161ccfc2d950f5873a88acc0980b00000000001976a9141ce37825ea5408646bacb480be4dc96eb7e8a0ae88ac0027b929000000001976a914b5cc5d8ed2bc8c5c4d84778dc492d8a8f37f573788acf00c1417000000001976a914a4037f508bc342d86e6a1f70955d5a5325707efa88ac29b037a0000000001976a91456e331dc6792323194f4c624e59b8dbd85ac3b1f88ac202d2d6c000000001976a9142a6a3985ab3b8d3531036427890fdb300c8cd6b588ac00000000",
  "error": null,
  "id": "1"
}

```

### curl decoderawtransaction

```
curl -X POST http://127.0.0.1:8332/ -u user:pass -H 'content-type:text/plain;'  \
-d '{"jsonrpc":"1.0","id":"1","method":"decoderawtransaction","params":["010000000d96387c7...d9016b1ac471e219c"]}'

{
  "txid": "115a0f0edbe0fe7250796478df1d3467bb9a6b9ff34921d431ace1417bafd2c1",
  "hash": "115a0f0edbe0fe7250796478df1d3467bb9a6b9ff34921d431ace1417bafd2c1",
  "version": 1,
  "size": 2202,
  "vsize": 2202,
  "weight": 8808,
  "locktime": 0,
  "vin": [{
      "txid": "6339e7624121661c2454c424542f2e20e64943e1b45f68c91c7ad4657b7c3896",
      "vout": 1,
      "scriptSig": {
        "asm": "3045022100fd515538fa0c24aed7bd3f9a0a7d4c3986a47f4790c9ff535cae365b923bf7b2022015df2122618d86afda9444cfceffd5357f933e73c0b310b6542074c4a40b8e3f[ALL] 02372801dfabd914cb3f313a9a6732af986ca037fe085a7fa8e5395dc270e43341",
        "hex": "483045022100fd515538fa0c24aed7bd3f9a0a7d4c3986a47f4790c9ff535cae365b923bf7b2022015df2122618d86afda9444cfceffd5357f933e73c0b310b6542074c4a40b8e3f012102372801dfabd914cb3f313a9a6732af986ca037fe085a7fa8e5395dc270e43341"
      },
      "sequence": 4294967295
    },
    {
      "txid": "6339e7624121661c2454c424542f2e20e64943e1b45f68c91c7ad4657b7c3896",
      "vout": 14,
      "scriptSig": {
        "asm": "3045022100c5bb04c7a02f2942ae2d2df8eb74b011803b3ddc998033bc2d96febcaf9914e002206800e0941d1211a14881d9b3ac948329cd4e0d4178ada50a05b4d564c8a92940[ALL] 02e12d207bb38491afb9f5b9813936287448ce22ddd29162c0e9c9acbf012c9911",
        "hex": "483045022100c5bb04c7a02f2942ae2d2df8eb74b011803b3ddc998033bc2d96febcaf9914e002206800e0941d1211a14881d9b3ac948329cd4e0d4178ada50a05b4d564c8a92940012102e12d207bb38491afb9f5b9813936287448ce22ddd29162c0e9c9acbf012c9911"
      },
      "sequence": 4294967295
    },
    {
      "txid": "9e098f499ab4648c25931b066b0c8d55b747ed2738edd4c7c2888a1ef23d714f",
      "vout": 4,
      "scriptSig": {
        "asm": "30450221008f7f4e724c65e34beff1626a6258353cbe4b00e19d3ccddb2cad8ab496719bfa0220406fc719fe2d50db174ab862416e7fda59134db016604e83885539a63f8d8d8a[ALL] 03763678ff1a57286a63ef649c8819eea06d850fe69bc1b8e76de824e17d9c4e44",
        "hex": "4830450221008f7f4e724c65e34beff1626a6258353cbe4b00e19d3ccddb2cad8ab496719bfa0220406fc719fe2d50db174ab862416e7fda59134db016604e83885539a63f8d8d8a012103763678ff1a57286a63ef649c8819eea06d850fe69bc1b8e76de824e17d9c4e44"
      },
      "sequence": 4294967295
    },
    {
      "txid": "1e8580330e62a95ca9d49f0bbefe9c4c56044ef67187fb3d682dd2c23fe73866",
      "vout": 19,
      "scriptSig": {
        "asm": "3045022100f8a218918126bb317999936cf181c5354a37139e006f9e99086bd0aa43a8a8d10220599fd4fe697df8332e0870377c22f79dee5b2e22cca0b269d48c6216844c2116[ALL] 036058456f982a31e5ae85b33d10c73f973fa04dcda5bef203053764c66c1987f5",
        "hex": "483045022100f8a218918126bb317999936cf181c5354a37139e006f9e99086bd0aa43a8a8d10220599fd4fe697df8332e0870377c22f79dee5b2e22cca0b269d48c6216844c21160121036058456f982a31e5ae85b33d10c73f973fa04dcda5bef203053764c66c1987f5"
      },
      "sequence": 4294967295
    },
    {
      "txid": "3af1d1b4b318bf32150d38cbfffaff8893b54676993b6da87bd65ff22d2a0b59",
      "vout": 0,
      "scriptSig": {
        "asm": "3045022100bb83b1f198ca579b687a74fab118c47a5da74c03b2eff250fa9cf8364a8aa6e80220114f36ff5cac8f82ab04d8f992325625f79b6131aaf5e95a63a7294e0c18aa43[ALL] 0349f729cb92967f56857c173f32c00ce11d8b1695cecd70930e234f6c450aa805",
        "hex": "483045022100bb83b1f198ca579b687a74fab118c47a5da74c03b2eff250fa9cf8364a8aa6e80220114f36ff5cac8f82ab04d8f992325625f79b6131aaf5e95a63a7294e0c18aa4301210349f729cb92967f56857c173f32c00ce11d8b1695cecd70930e234f6c450aa805"
      },
      "sequence": 4294967295
    },
    {
      "txid": "6339e7624121661c2454c424542f2e20e64943e1b45f68c91c7ad4657b7c3896",
      "vout": 12,
      "scriptSig": {
        "asm": "30450221009b907423f565d61d74008820aebf3a810d4adc39206c52a74936c2ab26df2e7002201f381a38754394257cfc7c109a6fa68cb58f1b2b4d90d60fe5e348162b907052[ALL] 02aed673e7e11a16837eb90334952a5a8e6c1c8cf0f79221687fae1e933f53e51c",
        "hex": "4830450221009b907423f565d61d74008820aebf3a810d4adc39206c52a74936c2ab26df2e7002201f381a38754394257cfc7c109a6fa68cb58f1b2b4d90d60fe5e348162b907052012102aed673e7e11a16837eb90334952a5a8e6c1c8cf0f79221687fae1e933f53e51c"
      },
      "sequence": 4294967295
    },
    {
      "txid": "606d53c88f90f77c9e86acceeb9198048d754c3688e9112209d8924706eb92a8",
      "vout": 0,
      "scriptSig": {
        "asm": "30450221009998a86a7d6819ad5ad54b02616aba1c08651b7a856a078808fffd683840bb1402204b5e351faa402a43d630aa4ac6396e2025275725f207117552c7b27839f0913d[ALL] 03fad4d5612d89be07d4bc228f1a17b3268ba61810dd9311cbc2ea7264ca5431d2",
        "hex": "4830450221009998a86a7d6819ad5ad54b02616aba1c08651b7a856a078808fffd683840bb1402204b5e351faa402a43d630aa4ac6396e2025275725f207117552c7b27839f0913d012103fad4d5612d89be07d4bc228f1a17b3268ba61810dd9311cbc2ea7264ca5431d2"
      },
      "sequence": 4294967295
    },
    {
      "txid": "af87a4202407e3b0e3981da515708965ef2fe1ec37e4d48c018ce14fbebac87a",
      "vout": 0,
      "scriptSig": {
        "asm": "304502210081a93055cd07a21cd6959e6f6529b27a51adf70c2f8bf47005406a9417426cf8022014c75eb48b4303a61dc931132eee57aa877e6ba50bb9d3da0f3ccb0b09d7d68a[ALL] 023a83a94ec2e9f82d822bd7fbc97a884d905af7173c99845424d0a7416c4cdc50",
        "hex": "48304502210081a93055cd07a21cd6959e6f6529b27a51adf70c2f8bf47005406a9417426cf8022014c75eb48b4303a61dc931132eee57aa877e6ba50bb9d3da0f3ccb0b09d7d68a0121023a83a94ec2e9f82d822bd7fbc97a884d905af7173c99845424d0a7416c4cdc50"
      },
      "sequence": 4294967295
    },
    {
      "txid": "dd01e1ce4532045b0052b5181d027c729b9f6b0a6bb318060238261668e95fb6",
      "vout": 15,
      "scriptSig": {
        "asm": "3045022100bb21987e7a2587752329fedc665745e266d1163038f26028795b751407fbd5a1022003086167ef646126b026d309e6ea7285e07dfbd0f0e63bcc99222f4432edd959[ALL] 0261508e81863e3da237935f0cbc14449a5c932bf616955171e562c10b0e2227dc",
        "hex": "483045022100bb21987e7a2587752329fedc665745e266d1163038f26028795b751407fbd5a1022003086167ef646126b026d309e6ea7285e07dfbd0f0e63bcc99222f4432edd95901210261508e81863e3da237935f0cbc14449a5c932bf616955171e562c10b0e2227dc"
      },
      "sequence": 4294967295
    },
    {
      "txid": "6339e7624121661c2454c424542f2e20e64943e1b45f68c91c7ad4657b7c3896",
      "vout": 16,
      "scriptSig": {
        "asm": "304402207b28a0e3972db06658568d68bbe658d215d1aade783b63cb06e53ed5dfa552c40220069054745a87f666e9dbf9037c463a3e6db6bf52654e53651a0be8811aca6945[ALL] 021969a96c51157aa4d606b93ceedc5d539961ffc54edb1fd0e562c45eb6f3f8a3",
        "hex": "47304402207b28a0e3972db06658568d68bbe658d215d1aade783b63cb06e53ed5dfa552c40220069054745a87f666e9dbf9037c463a3e6db6bf52654e53651a0be8811aca69450121021969a96c51157aa4d606b93ceedc5d539961ffc54edb1fd0e562c45eb6f3f8a3"
      },
      "sequence": 4294967295
    },
    {
      "txid": "d3e877d1e7e71d047bdf03c2a622a89e124c1cca8bdea2687bf44ab99ce316de",
      "vout": 19,
      "scriptSig": {
        "asm": "30440220591a4f57c3b9cd7e980f94157dc53eee2505169cf67a970d74bf5687d8afb474022049be8389b836dc448a5f748273cf4c8417426be5d4bcadd46f4038c208b740ab[ALL] 035428cb8056f3e52221a0736588c0c72f5ace90e86855342f673610f8b5604a40",
        "hex": "4730440220591a4f57c3b9cd7e980f94157dc53eee2505169cf67a970d74bf5687d8afb474022049be8389b836dc448a5f748273cf4c8417426be5d4bcadd46f4038c208b740ab0121035428cb8056f3e52221a0736588c0c72f5ace90e86855342f673610f8b5604a40"
      },
      "sequence": 4294967295
    },
    {
      "txid": "67ed10e2a6e87ee2ddb3fc848a1bb7817e59a12db751c697904f70f7aee8917a",
      "vout": 14,
      "scriptSig": {
        "asm": "304402205c76cd5810cac4f119cf0b40ceee5005bbb4b877bf7cd5de87c293867752a32702207142269cfe87c1a89cac2159c86adb4f3a21812d0049eaa78245ccb5976fce34[ALL] 029e9aad07f57a8ca071e7dc754920393b60fb0a7d8e549ded24be31f9e788de67",
        "hex": "47304402205c76cd5810cac4f119cf0b40ceee5005bbb4b877bf7cd5de87c293867752a32702207142269cfe87c1a89cac2159c86adb4f3a21812d0049eaa78245ccb5976fce340121029e9aad07f57a8ca071e7dc754920393b60fb0a7d8e549ded24be31f9e788de67"
      },
      "sequence": 4294967295
    },
    {
      "txid": "8b374904842e399ca9f585c06b05c3c119e271c41a6b01d9b0bda3de6d52010a",
      "vout": 0,
      "scriptSig": {
        "asm": "304402202fdee85d0ba26045d3f367ed035a4794c6f0b0cb6da0093e56e711e62e4e711c0220231e78b6c63043420162a3fe299cd4d60b44329a9193ce035d70e1370456c36b[ALL] 039dc0fbb2f2f4f03a51467bdc10ef513c919959bd56a668f3a412db6e03b4bc23",
        "hex": "47304402202fdee85d0ba26045d3f367ed035a4794c6f0b0cb6da0093e56e711e62e4e711c0220231e78b6c63043420162a3fe299cd4d60b44329a9193ce035d70e1370456c36b0121039dc0fbb2f2f4f03a51467bdc10ef513c919959bd56a668f3a412db6e03b4bc23"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [{
      "value": 0.05958225,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 bae698c673a97da3e0c3e0d3769332aa03e51420 OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(1J3Evpswz2ktcD3uFzx83RMjXbwG4Vrm4p)#7ljdtrdg",
        "hex": "76a914bae698c673a97da3e0c3e0d3769332aa03e5142088ac",
        "address": "1J3Evpswz2ktcD3uFzx83RMjXbwG4Vrm4p",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 40.17164257,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 2abe97e47fc446f49c65631225fd0db636d793b6 OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(14u1hiPez1vM97hxTvr55wW5ieQmwPjUyr)#4mq3hnde",
        "hex": "76a9142abe97e47fc446f49c65631225fd0db636d793b688ac",
        "address": "14u1hiPez1vM97hxTvr55wW5ieQmwPjUyr",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 18.89454257,
      "n": 2,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 eb19735b3857504d17ee3e161ccfc2d950f5873a OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(1NS6HRLTk5Djp3dnhAgNYxLjp7NgUkhdjz)#wgytxtek",
        "hex": "76a914eb19735b3857504d17ee3e161ccfc2d950f5873a88ac",
        "address": "1NS6HRLTk5Djp3dnhAgNYxLjp7NgUkhdjz",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 0.00760000,
      "n": 3,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 1ce37825ea5408646bacb480be4dc96eb7e8a0ae OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(13dkRDbvEqGajXZdXb11PQsJGPF61LV1Lx)#ugz6sklm",
        "hex": "76a9141ce37825ea5408646bacb480be4dc96eb7e8a0ae88ac",
        "address": "13dkRDbvEqGajXZdXb11PQsJGPF61LV1Lx",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 7.00000000,
      "n": 4,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 b5cc5d8ed2bc8c5c4d84778dc492d8a8f37f5737 OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(1HaG8HP8Z7FmRMDtak5EfpUatTc8M2jHsV)#q0vpqdke",
        "hex": "76a914b5cc5d8ed2bc8c5c4d84778dc492d8a8f37f573788ac",
        "address": "1HaG8HP8Z7FmRMDtak5EfpUatTc8M2jHsV",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 3.87190000,
      "n": 5,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 a4037f508bc342d86e6a1f70955d5a5325707efa OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(1FxE1TbBLidu6uBEpwUG9gGxnqk1RxirKx)#ahlj4wju",
        "hex": "76a914a4037f508bc342d86e6a1f70955d5a5325707efa88ac",
        "address": "1FxE1TbBLidu6uBEpwUG9gGxnqk1RxirKx",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 26.88004137,
      "n": 6,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 56e331dc6792323194f4c624e59b8dbd85ac3b1f OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(18vRHGUJ2kPLzg9uBtYvFCFNmqGfjWyNs4)#qcpcrsc9",
        "hex": "76a91456e331dc6792323194f4c624e59b8dbd85ac3b1f88ac",
        "address": "18vRHGUJ2kPLzg9uBtYvFCFNmqGfjWyNs4",
        "type": "pubkeyhash"
      }
    },
    {
      "value": 18.14900000,
      "n": 7,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 2a6a3985ab3b8d3531036427890fdb300c8cd6b5 OP_EQUALVERIFY OP_CHECKSIG",
        "desc": "addr(14sGdgLFs9f1VtWsEjT46vScMDZRAQer8V)#vq27ptua",
        "hex": "76a9142a6a3985ab3b8d3531036427890fdb300c8cd6b588ac",
        "address": "14sGdgLFs9f1VtWsEjT46vScMDZRAQer8V",
        "type": "pubkeyhash"
      }
    }
  ]
}
```

### python script

```python
import json
import requests

url = "http://127.0.0.1:8332/"
auth=("user", "pass")
payload = json.dumps({"method": 'getblockhash', "params": [1] })

response = requests.request("POST", url, data=payload, auth=auth)
print(response.text)
```

```python
# https://github.com/bibajz/bitcoin-python-async-rpc
import asyncio
from bitcoinrpc import BitcoinRPC

async def main():

    rpcurl = ""
    async with BitcoinRPC.from_config(rpcurl, ("user", "pass")) as rpc:
        print(await rpc.getconnectioncount())
        max_height = await rpc.getblockcount()
        print("max_height: ", max_height)
        blk_hash = await rpc.getblockhash(max_height)
        print("blk_hash: ", blk_hash)
        block = await rpc.getblock(blk_hash)
        txs = block['tx']
        print(txs[1])
        tx = await rpc.getrawtransaction(txs[0])
        print(tx)

if __name__ == "__main__":
    asyncio.run(main())
```


----

参考：

https://bitcoincore.org/bin
https://bitcoin.org/en/release/v0.17.0#configuration-sections-for-testnet-and-regtest
https://github.com/blockchain-etl/bitcoin-etl
https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)
https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_calls_list
https://bitcoin.stackexchange.com/questions/19665/json-rpc-via-curl