使用ToastWallet管理Ripple私链账户资金
默认的ToastWallet接口服务器
指定私链本地接口服务器
导入创世账号和其他在私链上已生成并注资激活的账号
使用ToastWallet管理Ripple私链账户资金
默认的ToastWallet接口服务器
指定私链本地接口服务器
导入创世账号和其他在私链上已生成并注资激活的账号
Ripple交易方法之sign交易签名字段说明
https://developers.ripple.com/sign.html
交易签名请求格式
{ "method": "sign", "params": [ { "offline": false, "secret": "s████████████████████████████", "tx_json": { "Account": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "Amount": { "currency": "USD", "issuer": "rf1BiGeXwwQoi8Z2ueFYTEXSwuJYfV2Jpn", "value": "1" }, "Destination": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", "TransactionType": "Payment" }, "fee_mult_max": 1000 } ] }
签名方法字段
offline:默认为为false,在提交签名时,自动填充部分字段。 secret:交易签名,可替换为seed/seed_hex/passphrase,但此三种类型需要额外指定key_type字段。 build_path:在交易类型为Payment交易时,自动指定填充Paths字段,即路径发现。 fee_mult_max:限制自动填充Fee字段的最高值,默认为10,建议为1000。受基于负载的交易成本影响,如果(base_fee_xrp × load_factor)> (fee_mult_max ÷ fee_div_max), 则签名失败 fee_div_max:可选,默认为1,如果指定Fee字段,则自动忽略。
自动填充的字段
Sequnece字段:自动填充交易发送方的下一交易序号,在交易生效前该序号不会自增。如果提交多个交易而未等待每个交易相应,则应手工指定后续交易序号。 Fee字段:省略该字段时时,自动填充字段。在生产网络上不指定fee_mult_max则会提示rpcHIGH_FEE错误。 Pahts字段:对于非XRP到XRP的Payment交易有效,自动填充Paths字段,仅在指定build_path字段时有效。
响应字段
tx_blob:以十六进制表示的已签名二进制交易信息。 tx_json:已签名的完整JSON格式交易信息,包括自动填充的字段。
Ripple管理rippled服务器之集群rippled服务器
https://developers.ripple.com/cluster-rippled-servers.html
https://developers.ripple.com/validation_create.html
Cluster rippled Servers
集群rippled服务器
If you are running multiple rippled servers in a single datacenter, you can configure those servers into a cluster to maximize efficiency. Running your rippled servers in a cluster provides the following benefits:
如果用户在单个数据中心中运行多个ripple服务器实例的话,Ripple建议这些服务器集群化以提升效率。在集群模式下运行rippled服务器将带来以下优势:
Clustered rippled servers share the work of cryptography. If one server has verified the authenticity of a message, the other servers in the cluster trust it and do not re-verify.
集群化的rippled服务器共享密码学工作。如果一台服务器已验证一条消息的真实性,则集群中的其他服务器将直接信息该消息而不再重复验证。
Clustered servers share information about peers and API clients that are misbehaving or abusing the network. This makes it harder to attack all servers of the cluster at once.
集群化的服务器共享有关对等节点和API客户端不当或滥用网络的信息。使其很难一次性攻击集群中的所有服务器。
Clustered servers always propagate transactions throughout the cluster, even if the transaction does not meet the current load-based transaction fee on some of them.
集群化的服务器始终在集群中传递交易,即使该交易不满足某些服务器上基于负载的交易费用要求。
To enable clustering, change the following sections of your config file for each server:
要启用集群,在要加入集群的每个服务器中修改配置文件的以下部分:
List the IP address and port of each other server under the [ips_fixed] section. The port should be the one from the other servers’ protocol = peer setting in their rippled.cfg. Example:
在[ips_fixed]中列出所有其他对端服务器IP和端口号。端口号必须是对端服务器中配置文件所指定的端口号。
[ips_fixed]
192.168.0.1 51235
192.168.0.2 51235
Generate a unique seed (using the validation_create method) for each of your servers, and configure it under the [node_seed] section. The rippled server uses this key to sign its messages to other servers in the peer-to-peer network.
为每个服务器生成唯一种子(使用validation_create方法),并在[node_seed]下配置。rippled服务器使用这个密钥在P2P网络中签名其消息。
Add the public keys (for peer communication) of each of your other servers under the [cluster_nodes] section.
在[cluster_nodes]中添加其他每个服务器的公钥(用于对等网络通信)。
集群节点种子的生成示例
[root@rippled ~]# rippled validation_create Loading: "/etc/opt/ripple/rippled.cfg" 2018-Aug-10 08:07:19.453274432 HTTPClient:NFO Connecting to 127.0.0.1:5005 { "result" : { "status" : "success", "validation_key" : "ANNA GEM DATA WAD MIRE WAS JUNO GOLF HOT TINA JEFF HOOD", "validation_private_key" : "pa18XCwH3Kkg9Eu2gGns7UBMDE9crZUs8q2hqUkrdp8dxS832pw", "validation_public_key" : "n9JmBJKugB6NJBnnLMvFGsvph8A6kuLLWkJ65oX2QAarf2MaCWGH", "validation_seed" : "ssR4ENi7YxdQBjKWrwD5WTcuDRF6q" } } [root@rippled ~]#
Ripple为历史交易数据查询启用总账历史维护
查看节点node的本地总账数据库编号范围
[tom@node ripple]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 06:58:46.893224092 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "9-140454", [tom@node ripple]$
查询一笔先前提交的交易详情
[tom@node ripple]$ rippled tx 6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D --conf /usr/local/ripple/etc/rippled.cfg Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 06:58:52.518035660 HTTPClient:NFO Connecting to 127.0.0.1:8008 { "result" : { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", "Flags" : 2147483648, "RegularKey" : "rac2ReJMqmtpUAysDiNnxurmEY6iwVns82", "Sequence" : 1, "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType" : "SetRegularKey", "TxnSignature" : "30440220011A56103E3FCFD990879A9E7BE30F9FF3DA618227772C23513D97FCF7E9FBF502201C2A15D155F73615B3C05FEA936DCDE320323B1549B19A30AC02E7DB91FDF9E3", "date" : 586519652, "hash" : "6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D", "inLedger" : 891, "ledger_index" : 891, "meta" : { "AffectedNodes" : [ { "ModifiedNode" : { "FinalFields" : { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Balance" : "99999999999999990", "Flags" : 65536, "OwnerCount" : 0, "RegularKey" : "rac2ReJMqmtpUAysDiNnxurmEY6iwVns82", "Sequence" : 2 }, "LedgerEntryType" : "AccountRoot", "LedgerIndex" : "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8", "PreviousFields" : { "Balance" : "100000000000000000", "Flags" : 0, "Sequence" : 1 } } } ], "TransactionIndex" : 0, "TransactionResult" : "tesSUCCESS" }, "status" : "success", "validated" : true } } [tom@node ripple]$
在一个较晚加入私链网络的节点test中查看当前已完成的总账数据库编号范围
[tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 06:59:33.065045846 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "86363-140471", [tom@test ~]$
查询交易详情,提示无法找到交易
[tom@test ~]$ rippled tx 6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D --conf /usr/local/ripple/etc/rippled.cfg Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:00:39.579715595 HTTPClient:NFO Connecting to 127.0.0.1:8008 { "result" : { "error" : "txnNotFound", "error_code" : 29, "error_message" : "Transaction not found.", "request" : { "command" : "tx", "transaction" : "6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D" }, "status" : "error" } } [tom@test ~]$
查询交易所在账本信息,提示未找到该账本
[tom@test ~]$ rippled ledger 891 --conf /usr/local/ripple/etc/rippled.cfg Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:00:44.318081015 HTTPClient:NFO Connecting to 127.0.0.1:8008 { "result" : { "error" : "lgrNotFound", "error_code" : 21, "error_message" : "ledgerNotFound", "request" : { "command" : "ledger", "ledger_index" : 891 }, "status" : "error" } } [tom@test ~]$
启用总账历史维护配置并重新启动节点服务
[ledger_history] full
启用总账历史维护配置后,当前节点已完成账本complete_ledgers编号范围向两端扩大
[tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:11:30.943085415 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "77754-140710", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:23:47.692259040 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "68996-140955", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:46:40.158108447 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "52277-141412", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 07:59:33.520702510 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "43083-141669", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 08:08:41.423772524 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "36331-141852", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 08:43:18.161251559 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "32570-142543", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 08:43:43.923573899 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "32570-142552", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 08:43:46.535821957 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "32570-142553", [tom@test ~]$
在不指定earliest_seq时,默认的已完成总账complete_ledgers最低值为32570,在私链上需指定该参数以包括该编号之前的历史总账。
[node_db] type=NuDB path=/usr/local/ripple/db/nudb advisory_delete=0 earliest_seq=1
已完成总账同步状态
[tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 08:54:03.283201753 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "27899-142758", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:09:17.659041802 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "16748-143063", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:31:28.145139033 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "645-143506", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:32:43.897708626 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "7-143531", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:32:47.002578477 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "7-143532", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:32:48.851592760 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "7-143533", [tom@test ~]$ rippled server_info --conf /usr/local/ripple/etc/rippled.cfg |grep complete Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:32:50.681739140 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "7-143533", [tom@test ~]$
当前私链对端节点已完成总账的状态信息
[tom@test ~]$ rippled peers --conf /usr/local/ripple/etc/rippled.cfg |grep complete_ledgers Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:33:20.473793774 HTTPClient:NFO Connecting to 127.0.0.1:8008 "complete_ledgers" : "11 - 143543", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "8 - 143543", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "9 - 143543", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "10 - 143543", "complete_ledgers" : "141542 - 143542", "complete_ledgers" : "141543 - 143543", "complete_ledgers" : "141543 - 143543", [tom@test ~]$
历史总账同步后查询交易所在总账信息
[tom@test ~]$ rippled ledger 891 --conf /usr/local/ripple/etc/rippled.cfg Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:34:04.257744351 HTTPClient:NFO Connecting to 127.0.0.1:8008 { "result" : { "ledger" : { "accepted" : true, "account_hash" : "DDF8DFF58D91375576EA026F01F50E3AE9B829440420878AF2D6282A6466287E", "close_flags" : 0, "close_time" : 586519652, "close_time_human" : "2018-Aug-02 10:07:32.000000000", "close_time_resolution" : 10, "closed" : true, "hash" : "EB702434D82270AFB4AFD952E5829C2741A40178CD0CD8ACBE53554031CE62FA", "ledger_hash" : "EB702434D82270AFB4AFD952E5829C2741A40178CD0CD8ACBE53554031CE62FA", "ledger_index" : "891", "parent_close_time" : 586519651, "parent_hash" : "0C38EB1DD432DBE4ED888C5AC9E21A12DB4770C25885BA35E7C42CA461B7FE1B", "seqNum" : "891", "totalCoins" : "99999999999999990", "total_coins" : "99999999999999990", "transaction_hash" : "D3DB2B4E309220CA89EB9521617F2314869519A7280C7747BD7585CF184922A3" }, "ledger_hash" : "EB702434D82270AFB4AFD952E5829C2741A40178CD0CD8ACBE53554031CE62FA", "ledger_index" : 891, "status" : "success", "validated" : true } }
历史总账同步后查询交易详情
[tom@test ~]$ rippled tx 6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D --conf /usr/local/ripple/etc/rippled.cfg Loading: "/usr/local/ripple/etc/rippled.cfg" 2018-Aug-07 09:34:12.003683590 HTTPClient:NFO Connecting to 127.0.0.1:8008 { "result" : { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Fee" : "10", "Flags" : 2147483648, "RegularKey" : "rac2ReJMqmtpUAysDiNnxurmEY6iwVns82", "Sequence" : 1, "SigningPubKey" : "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020", "TransactionType" : "SetRegularKey", "TxnSignature" : "30440220011A56103E3FCFD990879A9E7BE30F9FF3DA618227772C23513D97FCF7E9FBF502201C2A15D155F73615B3C05FEA936DCDE320323B1549B19A30AC02E7DB91FDF9E3", "date" : 586519652, "hash" : "6A7F157E02AB0E9E134D1F48110413ABF5CA29D61824E3358AAA516D3B6CB67D", "inLedger" : 891, "ledger_index" : 891, "meta" : { "AffectedNodes" : [ { "ModifiedNode" : { "FinalFields" : { "Account" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh", "Balance" : "99999999999999990", "Flags" : 65536, "OwnerCount" : 0, "RegularKey" : "rac2ReJMqmtpUAysDiNnxurmEY6iwVns82", "Sequence" : 2 }, "LedgerEntryType" : "AccountRoot", "LedgerIndex" : "2B6AC232AA4C4BE41BF49D2459FA4A0347E1B543A4C92FCEE0821C0201E2E9A8", "PreviousFields" : { "Balance" : "100000000000000000", "Flags" : 0, "Sequence" : 1 } } } ], "TransactionIndex" : 0, "TransactionResult" : "tesSUCCESS" }, "status" : "success", "validated" : true } } [tom@test ~]$