Bitcoin Forum
June 15, 2024, 05:51:15 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: walletcreatefundedpsbt RPC question  (Read 136 times)
Gabrics (OP)
Full Member
***
Offline Offline

Activity: 183
Merit: 112

Just digging around


View Profile WWW
July 13, 2020, 03:14:22 PM
 #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
ranochigo
Legendary
*
Offline Offline

Activity: 2982
Merit: 4193



View Profile
July 13, 2020, 03:36:21 PM
Last edit: July 13, 2020, 03:47:02 PM by ranochigo
 #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).

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Gabrics (OP)
Full Member
***
Offline Offline

Activity: 183
Merit: 112

Just digging around


View Profile WWW
July 13, 2020, 03:51:54 PM
 #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]
      }
   ]
}

achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6704


Just writing some code


View Profile WWW
July 13, 2020, 03:59:54 PM
 #4

The argument following the outputs is an integer for the locktime. The options come after that.

Gabrics (OP)
Full Member
***
Offline Offline

Activity: 183
Merit: 112

Just digging around


View Profile WWW
July 13, 2020, 05: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]
      }
   ]
}
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3430
Merit: 6704


Just writing some code


View Profile WWW
July 13, 2020, 09: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]
      }
   }
}

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!