Changeset View
Changeset View
Standalone View
Standalone View
src/rpc/rawtransaction.cpp
| Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { | ||||
| return; | return; | ||||
| } | } | ||||
| out.push_back(Pair("reqSigs", nRequired)); | out.push_back(Pair("reqSigs", nRequired)); | ||||
| out.push_back(Pair("type", GetTxnOutputType(type))); | out.push_back(Pair("type", GetTxnOutputType(type))); | ||||
| UniValue a(UniValue::VARR); | UniValue a(UniValue::VARR); | ||||
| for (const CTxDestination &addr : addresses) { | for (const CTxDestination &addr : addresses) { | ||||
| a.push_back(EncodeDestination(addr)); | a.push_back(EncodeDestination(addr, config)); | ||||
| } | } | ||||
| out.push_back(Pair("addresses", a)); | out.push_back(Pair("addresses", a)); | ||||
| } | } | ||||
| void TxToJSON(const Config &config, const CTransaction &tx, | void TxToJSON(const Config &config, const CTransaction &tx, | ||||
| const uint256 hashBlock, UniValue &entry) { | const uint256 hashBlock, UniValue &entry) { | ||||
| entry.push_back(Pair("txid", tx.GetId().GetHex())); | entry.push_back(Pair("txid", tx.GetId().GetHex())); | ||||
| ▲ Show 20 Lines • Show All 474 Lines • ▼ Show 20 Lines | static UniValue createrawtransaction(const Config &config, | ||||
| for (const std::string &name_ : addrList) { | for (const std::string &name_ : addrList) { | ||||
| if (name_ == "data") { | if (name_ == "data") { | ||||
| std::vector<uint8_t> data = | std::vector<uint8_t> data = | ||||
| ParseHexV(sendTo[name_].getValStr(), "Data"); | ParseHexV(sendTo[name_].getValStr(), "Data"); | ||||
| CTxOut out(Amount(0), CScript() << OP_RETURN << data); | CTxOut out(Amount(0), CScript() << OP_RETURN << data); | ||||
| rawTx.vout.push_back(out); | rawTx.vout.push_back(out); | ||||
| } else { | } else { | ||||
| CTxDestination destination = | CTxDestination destination = DecodeDestination(name_, config); | ||||
| DecodeDestination(name_, config.GetChainParams()); | |||||
| if (!IsValidDestination(destination)) { | if (!IsValidDestination(destination)) { | ||||
| throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, | ||||
| std::string("Invalid Bitcoin address: ") + | std::string("Invalid Bitcoin address: ") + | ||||
| name_); | name_); | ||||
| } | } | ||||
| if (!destinations.insert(destination).second) { | if (!destinations.insert(destination).second) { | ||||
| throw JSONRPCError( | throw JSONRPCError( | ||||
| ▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | static UniValue decodescript(const Config &config, | ||||
| ScriptPubKeyToJSON(config, script, r, false); | ScriptPubKeyToJSON(config, script, r, false); | ||||
| UniValue type; | UniValue type; | ||||
| type = find_value(r, "type"); | type = find_value(r, "type"); | ||||
| if (type.isStr() && type.get_str() != "scripthash") { | if (type.isStr() && type.get_str() != "scripthash") { | ||||
| // P2SH cannot be wrapped in a P2SH. If this script is already a P2SH, | // P2SH cannot be wrapped in a P2SH. If this script is already a P2SH, | ||||
| // don't return the address for a P2SH of the P2SH. | // don't return the address for a P2SH of the P2SH. | ||||
| r.push_back(Pair("p2sh", EncodeDestination(CScriptID(script)))); | r.push_back(Pair("p2sh", EncodeDestination(CScriptID(script), config))); | ||||
| } | } | ||||
| return r; | return r; | ||||
| } | } | ||||
| /** | /** | ||||
| * Pushes a JSON object for script verification or signing errors to vErrorsRet. | * Pushes a JSON object for script verification or signing errors to vErrorsRet. | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 489 Lines • Show Last 20 Lines | |||||