Skip to content

Commit 03fe70c

Browse files
MarcoFalkeMunkybooty
authored andcommitted
Merge bitcoin#13899: build: Enable -Wredundant-decls where available. Remove redundant redeclarations.
d56b73f Remove redundant extern (practicalswift) f04bb13 Enable -Wredundant-decls (gcc) if available (practicalswift) a9e90e5 Remove redundant redeclaration of rescanblockchain(...) in same scope (practicalswift) Pull request description: Remove redundant redeclaration of `rescanblockchain` and enable `-Wredundant-decls` (gcc) where available to avoid accidental redundant redeclarations. ``` CXX wallet/libbitcoin_wallet_a-rpcwallet.o wallet/rpcwallet.cpp:4764:17: warning: redundant redeclaration of ‘UniValue rescanblockchain(const JSONRPCRequest&)’ in same scope [-Wredundant-decls] extern UniValue rescanblockchain(const JSONRPCRequest& request); ^~~~~~~~~~~~~~~~ wallet/rpcwallet.cpp:3929:10: note: previous declaration of ‘UniValue rescanblockchain(const JSONRPCRequest&)’ UniValue rescanblockchain(const JSONRPCRequest& request) ^~~~~~~~~~~~~~~~ ``` Tree-SHA512: b9af95fa53f494c3f6702e485956b66b042d2ff7578b4a53bf28e91aa844cdcf5d7ac3e2e710948eed566007324e81317304b8eabf2d4ea284cd6acd77f8ffcd # Conflicts: # configure.ac # src/wallet/rpcwallet.cpp
1 parent 5d38c82 commit 03fe70c

File tree

1 file changed

+182
-4
lines changed

1 file changed

+182
-4
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 182 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4344,6 +4344,188 @@ static UniValue listlabels(const JSONRPCRequest& request)
43444344
return ret;
43454345
}
43464346

4347+
4348+
UniValue dumphdinfo(const JSONRPCRequest& request);
4349+
UniValue importelectrumwallet(const JSONRPCRequest& request);
4350+
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
4351+
return NullUniValue;
4352+
}
4353+
4354+
if (request.fHelp || request.params.size() < 1 || request.params.size() > 4)
4355+
throw std::runtime_error(
4356+
"walletprocesspsbt \"psbt\" ( sign \"sighashtype\" bip32derivs )\n"
4357+
"\nUpdate a PSBT with input information from our wallet and then sign inputs\n"
4358+
"that we can sign for.\n"
4359+
+ HelpRequiringPassphrase(pwallet) + "\n"
4360+
4361+
"\nArguments:\n"
4362+
"1. \"psbt\" (string, required) The transaction base64 string\n"
4363+
"2. sign (boolean, optional, default=true) Also sign the transaction when updating\n"
4364+
"3. \"sighashtype\" (string, optional, default=ALL) The signature hash type to sign with if not specified by the PSBT. Must be one of\n"
4365+
" \"ALL\"\n"
4366+
" \"NONE\"\n"
4367+
" \"SINGLE\"\n"
4368+
" \"ALL|ANYONECANPAY\"\n"
4369+
" \"NONE|ANYONECANPAY\"\n"
4370+
" \"SINGLE|ANYONECANPAY\"\n"
4371+
"4. bip32derivs (boolean, optiona, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them\n"
4372+
4373+
"\nResult:\n"
4374+
"{\n"
4375+
" \"psbt\" : \"value\", (string) The base64-encoded partially signed transaction\n"
4376+
" \"complete\" : true|false, (boolean) If the transaction has a complete set of signatures\n"
4377+
" ]\n"
4378+
"}\n"
4379+
4380+
"\nExamples:\n"
4381+
+ HelpExampleCli("walletprocesspsbt", "\"psbt\"")
4382+
);
4383+
4384+
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL, UniValue::VSTR});
4385+
4386+
// Unserialize the transaction
4387+
PartiallySignedTransaction psbtx;
4388+
std::string error;
4389+
if (!DecodePSBT(psbtx, request.params[0].get_str(), error)) {
4390+
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed %s", error));
4391+
}
4392+
4393+
// Get the sighash type
4394+
int nHashType = ParseSighashString(request.params[2]);
4395+
4396+
// Use CTransaction for the constant parts of the
4397+
// transaction to avoid rehashing.
4398+
const CTransaction txConst(*psbtx.tx);
4399+
4400+
// Fill transaction with our data and also sign
4401+
bool sign = request.params[1].isNull() ? true : request.params[1].get_bool();
4402+
bool bip32derivs = request.params[3].isNull() ? false : request.params[3].get_bool();
4403+
bool complete = FillPSBT(pwallet, psbtx, &txConst, nHashType, sign, bip32derivs);
4404+
4405+
UniValue result(UniValue::VOBJ);
4406+
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
4407+
ssTx << psbtx;
4408+
result.pushKV("psbt", EncodeBase64((unsigned char*)ssTx.data(), ssTx.size()));
4409+
result.pushKV("complete", complete);
4410+
4411+
return result;
4412+
}
4413+
4414+
UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
4415+
{
4416+
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
4417+
CWallet* const pwallet = wallet.get();
4418+
4419+
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
4420+
return NullUniValue;
4421+
}
4422+
4423+
if (request.fHelp || request.params.size() < 2 || request.params.size() > 6)
4424+
throw std::runtime_error(
4425+
"walletcreatefundedpsbt [{\"txid\":\"id\",\"vout\":n},...] [{\"address\":amount},{\"data\":\"hex\"},...] ( locktime ) ( replaceable ) ( options bip32derivs )\n"
4426+
"\nCreates and funds a transaction in the Partially Signed Transaction format. Inputs will be added if supplied inputs are not enough\n"
4427+
"Implements the Creator and Updater roles.\n"
4428+
"\nArguments:\n"
4429+
"1. \"inputs\" (array, required) A json array of json objects\n"
4430+
" [\n"
4431+
" {\n"
4432+
" \"txid\":\"id\", (string, required) The transaction id\n"
4433+
" \"vout\":n, (numeric, required) The output number\n"
4434+
" \"sequence\":n (numeric, optional) The sequence number\n"
4435+
" } \n"
4436+
" ,...\n"
4437+
" ]\n"
4438+
"2. \"outputs\" (array, required) a json array with outputs (key-value pairs)\n"
4439+
" [\n"
4440+
" {\n"
4441+
" \"address\": x.xxx, (obj, optional) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in " + CURRENCY_UNIT + "\n"
4442+
" },\n"
4443+
" {\n"
4444+
" \"data\": \"hex\" (obj, optional) A key-value pair. The key must be \"data\", the value is hex encoded data\n"
4445+
" }\n"
4446+
" ,... More key-value pairs of the above form. For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also\n"
4447+
" accepted as second parameter.\n"
4448+
" ]\n"
4449+
"3. locktime (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs\n"
4450+
"4. replaceable (boolean, optional, default=false) Marks this transaction as BIP125 replaceable.\n"
4451+
" Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.\n"
4452+
"5. options (object, optional)\n"
4453+
" {\n"
4454+
" \"changeAddress\" (string, optional, default pool address) The bitcoin address to receive the change\n"
4455+
" \"changePosition\" (numeric, optional, default random) The index of the change output\n"
4456+
" \"change_type\" (string, optional) The output type to use. Only valid if changeAddress is not specified. Options are \"legacy\", \"p2sh-segwit\", and \"bech32\". Default is set by -changetype.\n"
4457+
" \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
4458+
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n"
4459+
" \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific fee rate in " + CURRENCY_UNIT + "/kB\n"
4460+
" \"subtractFeeFromOutputs\" (array, optional) A json array of integers.\n"
4461+
" The fee will be equally deducted from the amount of each specified output.\n"
4462+
" The outputs are specified by their zero-based index, before any change output is added.\n"
4463+
" Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
4464+
" If no outputs are specified here, the sender pays the fee.\n"
4465+
" [vout_index,...]\n"
4466+
" \"replaceable\" (boolean, optional) Marks this transaction as BIP125 replaceable.\n"
4467+
" Allows this transaction to be replaced by a transaction with higher fees\n"
4468+
" \"conf_target\" (numeric, optional) Confirmation target (in blocks)\n"
4469+
" \"estimate_mode\" (string, optional, default=UNSET) The fee estimate mode, must be one of:\n"
4470+
" \"UNSET\"\n"
4471+
" \"ECONOMICAL\"\n"
4472+
" \"CONSERVATIVE\"\n"
4473+
" }\n"
4474+
"6. bip32derivs (boolean, optiona, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them\n"
4475+
"\nResult:\n"
4476+
"{\n"
4477+
" \"psbt\": \"value\", (string) The resulting raw transaction (base64-encoded string)\n"
4478+
" \"fee\": n, (numeric) Fee in " + CURRENCY_UNIT + " the resulting transaction pays\n"
4479+
" \"changepos\": n (numeric) The position of the added change output, or -1\n"
4480+
"}\n"
4481+
"\nExamples:\n"
4482+
"\nCreate a transaction with no inputs\n"
4483+
+ HelpExampleCli("walletcreatefundedpsbt", "\"[{\\\"txid\\\":\\\"myid\\\",\\\"vout\\\":0}]\" \"[{\\\"data\\\":\\\"00010203\\\"}]\"")
4484+
);
4485+
4486+
RPCTypeCheck(request.params, {
4487+
UniValue::VARR,
4488+
UniValueType(), // ARR or OBJ, checked later
4489+
UniValue::VNUM,
4490+
UniValue::VBOOL,
4491+
UniValue::VOBJ
4492+
}, true
4493+
);
4494+
4495+
CAmount fee;
4496+
int change_position;
4497+
CMutableTransaction rawTx = ConstructTransaction(request.params[0], request.params[1], request.params[2], request.params[3]);
4498+
FundTransaction(pwallet, rawTx, fee, change_position, request.params[4]);
4499+
4500+
// Make a blank psbt
4501+
PartiallySignedTransaction psbtx;
4502+
psbtx.tx = rawTx;
4503+
for (unsigned int i = 0; i < rawTx.vin.size(); ++i) {
4504+
psbtx.inputs.push_back(PSBTInput());
4505+
}
4506+
for (unsigned int i = 0; i < rawTx.vout.size(); ++i) {
4507+
psbtx.outputs.push_back(PSBTOutput());
4508+
}
4509+
4510+
// Use CTransaction for the constant parts of the
4511+
// transaction to avoid rehashing.
4512+
const CTransaction txConst(*psbtx.tx);
4513+
4514+
// Fill transaction with out data but don't sign
4515+
bool bip32derivs = request.params[5].isNull() ? false : request.params[5].get_bool();
4516+
FillPSBT(pwallet, psbtx, &txConst, 1, false, bip32derivs);
4517+
4518+
// Serialize the PSBT
4519+
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
4520+
ssTx << psbtx;
4521+
4522+
UniValue result(UniValue::VOBJ);
4523+
result.pushKV("psbt", EncodeBase64((unsigned char*)ssTx.data(), ssTx.size()));
4524+
result.pushKV("fee", ValueFromAmount(fee));
4525+
result.pushKV("changepos", change_position);
4526+
return result;
4527+
}
4528+
43474529
UniValue abortrescan(const JSONRPCRequest& request); // in rpcdump.cpp
43484530
UniValue dumpprivkey(const JSONRPCRequest& request); // in rpcdump.cpp
43494531
UniValue importprivkey(const JSONRPCRequest& request);
@@ -4354,10 +4536,6 @@ UniValue importwallet(const JSONRPCRequest& request);
43544536
UniValue importprunedfunds(const JSONRPCRequest& request);
43554537
UniValue removeprunedfunds(const JSONRPCRequest& request);
43564538
UniValue importmulti(const JSONRPCRequest& request);
4357-
UniValue rescanblockchain(const JSONRPCRequest& request);
4358-
4359-
UniValue dumphdinfo(const JSONRPCRequest& request);
4360-
UniValue importelectrumwallet(const JSONRPCRequest& request);
43614539

43624540
static const CRPCCommand commands[] =
43634541
{ // category name actor (function) argNames

0 commit comments

Comments
 (0)