Skip to content

Commit

Permalink
More concise conversion of CDataStream to string
Browse files Browse the repository at this point in the history
Use .str() instead of .data() and .size() when converting CDataStream to
a string. Uses std::string, avoiding conversion to a C string.
  • Loading branch information
gwillen committed Nov 1, 2018
1 parent 51e5ef3 commit fe5d22b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/rpc/rawtransaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,10 +1554,10 @@ UniValue finalizepsbt(const JSONRPCRequest& request)
mtx.vin[i].scriptWitness = psbtx.inputs[i].final_script_witness;
}
ssTx << mtx;
result.pushKV("hex", HexStr(ssTx.begin(), ssTx.end()));
result.pushKV("hex", HexStr(ssTx.str()));
} else {
ssTx << psbtx;
result.pushKV("psbt", EncodeBase64((unsigned char*)ssTx.data(), ssTx.size()));
result.pushKV("psbt", EncodeBase64(ssTx.str()));
}
result.pushKV("complete", complete);

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3842,7 +3842,7 @@ UniValue walletprocesspsbt(const JSONRPCRequest& request)
UniValue result(UniValue::VOBJ);
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
ssTx << psbtx;
result.pushKV("psbt", EncodeBase64((unsigned char*)ssTx.data(), ssTx.size()));
result.pushKV("psbt", EncodeBase64(ssTx.str()));
result.pushKV("complete", complete);

return result;
Expand Down Expand Up @@ -3956,7 +3956,7 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
ssTx << psbtx;

UniValue result(UniValue::VOBJ);
result.pushKV("psbt", EncodeBase64((unsigned char*)ssTx.data(), ssTx.size()));
result.pushKV("psbt", EncodeBase64(ssTx.str()));
result.pushKV("fee", ValueFromAmount(fee));
result.pushKV("changepos", change_position);
return result;
Expand Down

0 comments on commit fe5d22b

Please sign in to comment.