Author

Topic: walletcreatefundedpsbt RPC question (Read 162 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
July 13, 2020, 04:18:43 PM
#6
Locktime said "optional" in docs:
It is optional, but since you are using positional arguments instead of named arguments, it must be provided when you want to provide an argument positioned after it. Because you are doing positional arguemnts the parser doesn't know what each position corresponds to if one is missing.

To actually not provide it, you have to use named arguments. That would look like:
Code:
{
   "jsonrpc": "1.0",
   "id": 6,
   "method": "walletcreatefundedpsbt",
   "params": {"inputs": [{
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 0,
         "sequence": 0
      }, {
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 1,
         "sequence": 0
      }],
      "outputs": [{
         "tb1qgz5yfluv3n0sjcadxhmm3dk4xrwlglr88vsj8k": 0.00349723
      }],
        "options": {
         "subtractFeeFromOutputs":[0]
      }
   }
}
full member
Activity: 193
Merit: 121
Just digging around
July 13, 2020, 12:04:46 PM
#5
Locktime said "optional" in docs:
https://bitcoincore.org/en/doc/0.20.0/rpc/wallet/walletcreatefundedpsbt/
locktime                           (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs

Yes adding locktime did the trick, thank you!

This is the working JSON, combinding both advices, it may helps someone in the future:


{
   "jsonrpc": "1.0",
   "id": 6,
   "method": "walletcreatefundedpsbt",
   "params": [
      [{
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 0,
         "sequence": 0
      }, {
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 1,
         "sequence": 0
      }],
      [{
         "tb1qgz5yfluv3n0sjcadxhmm3dk4xrwlglr88vsj8k": 0.00349723
      }], 0, {
         "subtractFeeFromOutputs":[0]
      }
   ]
}
staff
Activity: 3458
Merit: 6793
Just writing some code
July 13, 2020, 10:59:54 AM
#4
The argument following the outputs is an integer for the locktime. The options come after that.
full member
Activity: 193
Merit: 121
Just digging around
July 13, 2020, 10:51:54 AM
#3
Just tried with integer.
Failed with same: "Expected type number, got object"

{
   "jsonrpc": "1.0",
   "id": 6,
   "method": "walletcreatefundedpsbt",
   "params": [
      [{
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 0,
         "sequence": 0
      }, {
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 1,
         "sequence": 0
      }],
      [{
         "tb1qgz5yfluv3n0sjcadxhmm3dk4xrwlglr88vsj8k": 0.00349723
      }], {
         "subtractFeeFromOutputs":[0]
      }
   ]
}

legendary
Activity: 3038
Merit: 4418
Crypto Swap Exchange
July 13, 2020, 10:36:21 AM
#2
An integer has to be specified in the field, as indicated by your error. Try replacing your string with the vout index of your outputs that you want to deduct the fees from (ie. 0).
full member
Activity: 193
Merit: 121
Just digging around
July 13, 2020, 10:14:22 AM
#1
Hi,

I am trying to RPC interface with Core and use walletcreatefundedpsbt with the following JSON:

{
   "jsonrpc": "1.0",
   "id": 6,
   "method": "walletcreatefundedpsbt",
   "params": [
      [{
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 0,
         "sequence": 0
      }, {
         "txid": "a77564bb72336febc5fe620bc67586dcc014bad6bb1c3aa53e3b01bb6159f241",
         "vout": 1,
         "sequence": 0
      }],
      [{
         "tb1qgz5yfluv3n0sjcadxhmm3dk4xrwlglr88vsj8k": 0.00349723
      }], {
         "subtractFeeFromOutputs": ["tb1qgz5yfluv3n0sjcadxhmm3dk4xrwlglr88vsj8k"]
      }
   ]
}

It fails with: Expected type number, got object.

But, it works if subtractFeeFromOutputs option is not used, so I assume options should be included somewhat differently.

Unfortunatelly docs or google didn't help me to solve this Sad

Can you please tell my how to modify this JSON?

Thanks
Jump to: