* 创建普通交易 * @return */
| 87 | * @return |
| 88 | */ |
| 89 | bool CreateCommonTx(string srcAddr, string desAddr) { |
| 90 | char fee[64] = {0}; |
| 91 | int nfee = GetRandomFee(); |
| 92 | sprintf(fee, "%d", nfee); |
| 93 | char money[64] = {0}; |
| 94 | int nmoney = GetRandomMoney(); |
| 95 | sprintf(money, "%d00000000", nmoney); |
| 96 | const char *argv[] = { "rpctest", "sendtoaddresswithfee", srcAddr.c_str(), desAddr.c_str(), money, fee}; |
| 97 | int argc = sizeof(argv) / sizeof(char*); |
| 98 | Value value; |
| 99 | if (!CommandLineRPC_GetValue(argc, argv, value)) { |
| 100 | return false; |
| 101 | } |
| 102 | const Value& result = find_value(value.get_obj(), "txid"); |
| 103 | if(result == null_type) { |
| 104 | return false; |
| 105 | } |
| 106 | string txid = result.get_str(); |
| 107 | vTransactionHash.push_back(txid); |
| 108 | if (mempool.mapTx.count(uint256(uint256S(txid))) > 0) { |
| 109 | std::shared_ptr<CBaseTx> tx = mempool.mapTx[uint256(uint256S(txid))].GetTransaction(); |
| 110 | vTransactions.push_back(tx); |
| 111 | } |
| 112 | vSendFee.push_back(make_pair(txid, nfee)); |
| 113 | return true; |
| 114 | } |
| 115 | /** |
| 116 | * 创建注册账户交易 |
| 117 | * @param addr |
nothing calls this directly
no test coverage detected