交易对手资产的小额支付中心客户。

picopayments-cli的Python项目详细描述


BuildLinkCoverageLinkLicenseLinkIssuesLink

交易对手资产的小额支付中心cli接口。

目前,python 3是受支持的版本。

设置

$ pip3 install picopayments-cli

用法

$ picopayments-cli [config arguments] <command> [command arguments]

用法示例

# show help text
$ picopayments-cli --help

# show help text for command
$ picopayments-cli <command> --help

# Show status of current connections
$ picopayments-cli --testnet status

# connect to hub
$ picopayments-cli --testnet connect ASSET QUANTITY

# queue payment
$ picopayments-cli --testnet queuepayment SOURCEHANDLE DESTINATIONHANDLE QUANTITY

# sync payments
$ picopayments-cli --testnet sync

# close payment channel
$ picopayments-cli --testnet close HANDLE

API调用/命令

版本

返回数字的当前版本。

轮毂状态

获取当前集线器状态。

参数

  • asset (str): Optionally limit output to given asset.

返回

List of open connections, current terms, funding addresses
and current liquidity for new connections.

{
  "connections": {
    "a0b1156206dedb1aa24084752b5693a9022349dc547fb9952aa510003e93": {
      "asset": "XCP",
      "balance": 31338,
      "status": "open",
      "ttl": 401
    }
  },
  "current_terms": {
    "XCP": {
      "deposit_max": 0,
      "deposit_min": 0,
      "deposit_ratio": 1.0,
      "expire_max": 0,
      "expire_min": 0,
      "sync_fee": 1
    }
  },
  "funding_addresses": {
    "BTC": "mhzPMMC3hkQUL9HUYY13s2NehEJXCA923Z",
    "XCP": "n1f73Cvxi7KFWK5p7W8F6JYbyQxV5djqUo"
  },
  "liquidity": {
    "addresses": {
      "XCP": [
        {
          "address": "mzEPqJet1LvZK5wjeDqmYx4udC3zx9oFwm",
          "balances": {
            "BTC": 333600,
            "XCP": 399876544
          }
        }
      ]
    },
    "total": {
      "BTC": 807814,
      "XCP": 599845207
    }
  }
}

余额

获取地址或当前钱包的余额。

参数

  • asset (str, default=None): Optionally filter for given asset.
  • address (str, default=None): Optionally provide address to check, uses wallet by default

返回

Dict mapping asset to available quantity in satoshis,
Unconfirmed assets are ignored.

{
    "BTC": 926109330,
    "XCP": 140982404156
}

搜索rawtxs

获取给定地址的原始事务。

参数

  • address (str): Address to get raw transactions for.
  • unconfirmed (bool, default=true): Include unconfirmed transactions.

返回

包含事务信息的dict列表。

示例

$ picopayments-cli --testnet searchrawtxs n2s5WgXPZvgKjtApHLk294gCditcDEKGJS
[
    {
        "blockhash": "0000000000000a835cdd31ad68496bd41c240471a5cdff3c07924646d441bd78",
        "blocktime": 1487152958,
        "confirmations": 31,
        "hex": "010000000135a32ea67f349fcae4bd272285663eec97c37bb2b816303bc44b26992b551cd9010000006a47304402207a89d42e1e61c7abead529b09f039ba2d3c585db88ddb233f9bb360cccd5c07002204ae361cc83610beb406b690bc62fad5af13d79919e724f039675f555c01b2b670121035f57228dc3b9a3224f2d48a1e2f9886f8412a0e77afdec28fd94dab7c7513b56ffffffff0340420f00000000001976a914ea28fc5a328d7f43c4a88e7a2edf1e1d8a8d60ae88ac00000000000000001e6a1c594663b76ecc1e31edd16d3b1ec19b0f4f983a71a70bed9465caa1cd8afc7100000000001976a914e63fe6f12b3300f2fad00a1270b71529985d972d88ac00000000",
        "locktime": 0,
        "size": 264,
        "time": 1487152958,
        "txid": "caf1f644777ed7b2b3eb6b5870368efe678eef738ba9c269560ad4414b3d1ce5",
        "version": 1,
        "vin": [
            {
                "scriptSig": {
                    "asm": "304402207a89d42e1e61c7abead529b09f039ba2d3c585db88ddb233f9bb360cccd5c07002204ae361cc83610beb406b690bc62fad5af13d79919e724f039675f555c01b2b67[ALL] 035f57228dc3b9a3224f2d48a1e2f9886f8412a0e77afdec28fd94dab7c7513b56",
                    "hex": "47304402207a89d42e1e61c7abead529b09f039ba2d3c585db88ddb233f9bb360cccd5c07002204ae361cc83610beb406b690bc62fad5af13d79919e724f039675f555c01b2b670121035f57228dc3b9a3224f2d48a1e2f9886f8412a0e77afdec28fd94dab7c7513b56"
                },
                "sequence": 4294967295,
                "txid": "d91c552b99264bc43b3016b8b27bc397ec3e66852227bde4ca9f347fa62ea335",
                "vout": 1
            }
        ],
        "vout": [
            {
                "n": 0,
                "scriptPubKey": {
                    "addresses": [
                        "n2s5WgXPZvgKjtApHLk294gCditcDEKGJS"
                    ],
                    "asm": "OP_DUP OP_HASH160 ea28fc5a328d7f43c4a88e7a2edf1e1d8a8d60ae OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914ea28fc5a328d7f43c4a88e7a2edf1e1d8a8d60ae88ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.01
            },
            {
                "n": 1,
                "scriptPubKey": {
                    "asm": "OP_RETURN 594663b76ecc1e31edd16d3b1ec19b0f4f983a71a70bed9465caa1cd",
                    "hex": "6a1c594663b76ecc1e31edd16d3b1ec19b0f4f983a71a70bed9465caa1cd",
                    "type": "nulldata"
                },
                "value": 0.0
            },
            {
                "n": 2,
                "scriptPubKey": {
                    "addresses": [
                        "n2WQGAvnDS1vf7uXToLou6kLxJXRGFHo2b"
                    ],
                    "asm": "OP_DUP OP_HASH160 e63fe6f12b3300f2fad00a1270b71529985d972d OP_EQUALVERIFY OP_CHECKSIG",
                    "hex": "76a914e63fe6f12b3300f2fad00a1270b71529985d972d88ac",
                    "reqSigs": 1,
                    "type": "pubkeyhash"
                },
                "value": 0.07470218
            }
        ]
    }
]

列表xos

获取给定地址的utxos。

参数

  • address (str): Address to get utxos for.
  • unconfirmed (bool, default=true): Include unconfirmed outputs.

返回

包含未使用事务输出信息的dict列表。

示例

$ picopayments-cli --testnet listutxos n2s5WgXPZvgKjtApHLk294gCditcDEKGJS
[
    {
        "amount": 0.01,
        "confirmations": 32,
        "scriptPubKey": "76a914ea28fc5a328d7f43c4a88e7a2edf1e1d8a8d60ae88ac",
        "txid": "caf1f644777ed7b2b3eb6b5870368efe678eef738ba9c269560ad4414b3d1ce5",
        "vout": 0
    }
]

getrawtx

获取单个事务的原始数据。

参数

  • txid (str): The transaction hash identifier.
  • verbose (bool, default=False): Include some additional information.

返回

如果找到,则原始事务对象的格式与 比特币GetRawTransaction API调用。如果找不到,就没有。

blocksend

通过区块链交易发送资金。

参数

  • asset (str): Asset to send.
  • destination (address): Address to receive the funds.
  • quantity (int): Quantity of the given asset to transfer.
  • extra_btc (int, default=0): Optional bitcoin to also be sent.

返回

txid of published transaction.

连接

创建与Hub的小额支付连接。

参数

  • asset (str): Asset to exchange in connection.
  • quantity (str): Quantity to be bound in the deposit, this determins the maximum amount that can bet transferred.
  • expire_time (int, default=1024): Time in blocks after which the deposit expires and can be recovered.
  • delay_time (int, default=2): Blocks hub must wait before payout, protects against publish revoked commits.

返回

{
    "send_deposit_txid": "published bitcoin transaction id",
    "handle": "handle for created connection"
}

排队支付

排队微支付通道发送(同步发送)。

参数

  • source (str): Handle of connection to send funds from.
  • destination (str): Handle of connection to receive funds.
  • quantity (int): Quantity of channel asset to transfer.
  • token (str, default=None): Optional token payee will receive with the payment.

返回

Provided token or generated token if None given.

状态

获取连接和钱包的状态。

参数

  • handle (str, default=None): Optionally limit to given handle.
  • verbose (bool, default=False): Optionally show additional information.

返回

{
  "connections": {
    "a0b206d1f68edb1aa24084752b5693a9022349dc547fb9952aa510003e93": {
      "asset": "XCP",
      "balance": 31337,
      "status": "open",
      "ttl": 404
    }
  },
  "wallet": {
    "address": "n2WQGAvnDS1vf7uXToLou6kLxJXRGFHo2b",
    "balances": {
      "BTC": 926109330,
      "XCP": 140982404156
    }
  }
}

同步

同步打开的连接并从关闭的连接中恢复资金。

这将按集线器条款中的定义为每个同步通道收取费用。

  • Synchronize open connections to send/receive payments.
  • Recover funds of closed connections.

参数

  • handle (str, default=None): Optionally limit to given handle.

返回

{
  "connection handle": {
    "txids": ["of transactions publish while recovering funds"],
    "received_payments": [
      {
        "payer_handle": "sender handle",
        "amount": 1337,
        "token": "provided by sender"
      }
    ]
  }
}

关闭

关闭打开的连接并固定到区块链。

历史

显示历史记录

参数

  • handle (str): Limit history to given channel.

返回

以前所做操作的列表。

剔除

如果已收回所有资金,则删除关闭的频道。

参数

  • handle (str): Optional handle of specific connection to be cull.

返回

已剔除连接的带句柄的列表。

取消付款

取消排队但未同步的付款。

参数

  • token (str): Token of the queued payment to be canceled.

返回

如果发现并取消付款,则为true,否则为false。

发球

启动rpc-api服务器。

参数

  • host (str): Network interface on which to host the service.
  • port (int): Network port on which to host the service.

测试指南

请随意在这里打开一个关于这个github项目的问题 你遇到的问题,我会尽快回答的。

请注意,所有测试当前都在testnet上,只使用 交易对手XCP资产。

# install the picopayments cli client (sorry no gui wallet just yet)
$ pip3 install picopayments-cli

# Show status of current connections and wallet
$ picopayments-cli --testnet status
# post the wallet address in https://community.storj.io/channel/micropayments-testing and you will be sent some funds for testing
# connect to hub (prints the hex handle of the created channel)
$ picopayments-cli --testnet connect XCP 1000000# you will have to wait until your deposit is confirmed, then the hub
# will match your deposit so you can recieve funds. After the hub deposit
# is confirmed the micropayment channel is open for use.
# Show status of current connections and wallet
$ picopayments-cli --testnet status

# Show hub status: open connections, liquidity, terms and funding addresses
$ picopayments-cli --testnet hubstatus

# queue payment
$ picopayments-cli --testnet queuepayment SOURCEHANDLE DESTINATIONHANDLE QUANTITY

# do not send more then you have or the other party can receive or it
# will mess up the channel (known issue I have to fix)
# sync payments (cost 1 xcp fee)
$ picopayments-cli --testnet sync

# close payment channel and settle to blockchain
$ picopayments-cli --testnet close HANDLE

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java GridBagLayout不填充区域   java Memozied Fibonacci未运行与常规Fibonacci解决方案   Java Web启动未启动问题   Java中异常和if-then的区别   java从命令提示符运行批处理文件获取错误   socket在Java中验证SSL证书的公共名称   如何在JAVA中检查字符串数组中的相等字   用java语言将音频文件转换成文本文件的语音识别   java为什么foo(1,2,3)没有传递给varargs方法foo(对象…)作为整数[]   java通过蓝牙将奇怪的数据从Arduino传输到Android   java ContainerRequestFilter获取空entitystream   java如何从安卓 studio中删除不兼容类型错误   基本Java错误   在Spring引导中使用REST API时发生java错误   javascript通过从SQL查询派生的URL打开页面