Bitcoin Forum
May 02, 2024, 11:20:42 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Bitcoin Technical Support / Re: getting JSON errors with createrawtransaction using python and python-bitcoinrpc on: August 13, 2021, 04:40:27 PM
I could narrow it down and found the fault in my code.
For inputs, I got a typing error for the key value. I used tixid instead of txid...
sorry guys, I feel kind of dumb... Roll Eyes but thanks a lot for bearing with me!!

script is working now. I appreciate the support! You guys are awesome!
2  Bitcoin / Bitcoin Technical Support / Re: getting JSON errors with createrawtransaction using python and python-bitcoinrpc on: August 10, 2021, 11:31:33 AM
based on the comment:
Quote
It's not enough to just convert them to strings as there are no quotes transmitted to the Bitcoin Core server.

I tried to add double quotes to the string like this: 
Code:
'"{}"'.format('txid'): '"{}"'.format('[i]mytxid[/i]')
inputs = [
    {
         '"tixid"': '"c1636efe3d85e3bb7e58663cfa976590ed1a9bb6740e7b851cbb34ab63f52ab9"',
         '"vout"': 2,
         '"sequence"': 4294967293
    }
]

but still an error:  JSON value is not a string as expected.

I guess I have to "force" python somehow to use double quotes in stade of single quotes for the strings inside the list...
but how... Huh
3  Bitcoin / Bitcoin Technical Support / Re: getting JSON errors with createrawtransaction using python and python-bitcoinrpc on: August 10, 2021, 11:17:49 AM
well the thing with json.dumps() is, that it converts the mylist or JSON array respectively into a string.
And the rpc does not accepts a string as JSON array.

Error: Expected type array, got string
4  Bitcoin / Bitcoin Technical Support / Re: getting JSON errors with createrawtransaction using python and python-bitcoinrpc on: August 10, 2021, 10:44:00 AM
what do you mean by rapping the entire JSON-RPC call around double quotes?

do you mean to represent the strings inside the JSON array with double quotes (instead of single quotes)?
like:
inputs = [
    {
         "tixid": "c1636efe3d85e3bb7e58663cfa976590ed1a9bb6740e7b851cbb34ab63f52ab9",
         "vout": 2,
         "sequence": 4294967293
    }
]


if so, this was my guess too.
But I don't know how to do that in python. because python uses single quotes in lists with dictionaries for strings...
as far as I understand , python does not care if you use double or single quotes for strings. But I assume that the JSON-RPC does care indeed...


so the question would be how to create a valid JSON array (with double quotes) in python for the JSON-RPC..?

Any suggestions?
5  Bitcoin / Bitcoin Technical Support / getting JSON errors with createrawtransaction using python and python-bitcoinrpc on: August 09, 2021, 09:57:26 PM
Hi

I am working on a python script using python-bitcoinrpc (https://github.com/jgarzik/python-bitcoinrpc).
Cofiguration is working and rpc.commands get executed.
But I am running into an error with "createrawtransaction".

I try
Code:
createrawtransaction(inputs, outputs, 0, True)
Error: "-1: JSON value is not a string as expected"

for the inputs and outputs I've set correspontig variables as lists, containing a dictionary/dictionaries with the relevant key:value pairs.
inputs: [
    {
         'tixid': 'c1636efe3d85e3bb7e58663cfa976590ed1a9bb6740e7b851cbb34ab63f52ab9',
         'vout': 2,
         'sequence': 4294967293
    }
]

outputs: [
    {
        'bc1q5q5e95h3z0eymfwasm2whx2jrztqa8sy012345': 0.012345
    },
    {
        'bc1q2gphxxpm7aetec0m7jpd04e342c5hree543210': 0.054321
    }
]


I tried to set all values as str() instead of float() or int(). Stille get the error "-1: JSON value is not a string as expected"...

I tried
Code:
createrawtransaction(json.dumps(inputs), json.dumps(outputs), 0, True)
Error: "expected type array, got string"
it seams like "createrawtransaction" does not accept the string value produced by json.dumps()....


As far as I can tell, my json array for the inputs and outputs are formated as described by https://bitcoincore.org/en/doc/0.21.0/rpc/rawtransactions/createrawtransaction/

What am I missing??
It almost looks like the python strings in my lists do not appear as strings to the bitcoin-cli.



I am running BitcoinCore 0.21.1, MacOs 11.4, python 3.9.4
6  Bitcoin / Bitcoin Technical Support / Re: bumpfee for transaction with specified changePosition on: August 08, 2021, 01:24:14 PM
Thx again @nc50lc for your help and clarification.

Does anyone have an idea for a solution to the problem/error I am running in to with the JSON array (described in reply #7) ?
7  Bitcoin / Bitcoin Technical Support / Re: bumpfee for transaction with specified changePosition on: August 05, 2021, 10:41:24 AM
also.... if I want to recreate a transaction with an op_return output, for example:
[ ...
      {
        "value": 0.00000000,
        "n": 1,
        "scriptPubKey": {
          "asm": "OP_RETURN 44464177010000aaee2c45de4d1b5ca89e1868f0367e3e729fa9d3d735547b72e863bf12cd7dea9 848100026c7b4f347444fe39a465185ebe714f80e4902501cd2c49f58a2ad89c397ab1234567890 a1",
          "hex": "6a4c5044464177010000aaee2c45de4d1b5ca89e1868f0367e3e729fa9d3d735547b72e863bf12c d7dea9848100026c7b4f347444fe39a465185ebe714f80e4902501cd2c49f58a2ad89c397ab1234 567890a1",
          "type": "nulldata"
        },
    ...
]

As described by https://bitcoincore.org/en/doc/0.21.0/rpc/rawtransactions/createrawtransaction/
the key:value pair is =  "data": "hex"

so for the example above: {["scriptPubKey"]["asm"]: ["scriptPubKey"]["hex"]}
I will then insert this in an jason array with other outputs to then use in:
createrawtransaction(inputs, outputs, 0, True)

is this correct to recreate a transaction with op_return ("nulldata") output?
8  Bitcoin / Bitcoin Technical Support / Re: bumpfee for transaction with specified changePosition on: August 05, 2021, 10:25:39 AM
Hi

I am still working (debugging) my python script to recreate my RBF tx to bump the fee.
But I am running into an error with "createrawtransaction".

Error: "-1: JSON value is not a string as expected"

I am using
Code:
createrawtransaction(inputs, outputs, 0, True)
inputs: [
    {
         'tixid': 'c1636efe3d85e3bb7e58663cfa976590ed1a9bb6740e7b851cbb34ab63f52ab9',
         'vout': 2,
         'sequence': 4294967293
    }
]

outputs: [
    {
        'bc1q5q5e95h3z0eymfwasm2whx2jrztqa8sy012345': 0.012345
    },
    {
        'bc1q2gphxxpm7aetec0m7jpd04e342c5hree543210': 0.054321
    }
]

I tried the output value as str() instead of float(). Stille get the error.

What am I missing??
As far as I can tell, my json array is formated as described by https://bitcoincore.org/en/doc/0.21.0/rpc/rawtransactions/createrawtransaction/


*Edit:
is e.g. 'txid' causing the error and should it be "txid"?
running MacOs 11.4 and python 3.9.4

*Edit2:
Could solve the problem. error comes from wrong key value in the input array. I got a typing error: "tixid" instead of "txid"
9  Bitcoin / Bitcoin Technical Support / Re: bumpfee for transaction with specified changePosition on: July 08, 2021, 02:34:20 PM
To have the change address as the last output is essential because I try to embed some information in a transaction.
The recipient of this transaction can only correctly verify the embedded data if the change address is defined as the last output. Otherwise, the embedded data gets mixed with my change address, and information would be invalid to the recipient.

So, I get a hex string of a rawtransaction (with the embedded information) which I input into a script.
The script handles the "fundrawtransaction", "signrawtransactionwithwallet" and "sendrawtransaction" command.

The goal is that the script automatically bumps the fee of this transaction (e.g., no confirmation over a certain period of time).

I guess it is the right start to use "decoderawtransaction" on my RBF-transaction and recreate it with same input(s) and outputs with "createrawtransaction", as described by @nc50lc.

I never used "creatrawtransaction" before. looks quite complex https://bitcoincore.org/en/doc/0.21.0/rpc/rawtransactions/createrawtransaction/
Not sure yet which information from "decoderawtransaction" I have to input in "creatrawtransaction".
Also, it is not possible to specify a feerate. To bump the fee of my RBF-transaction, I would have to deduct a certain amount from the output to the change address in the process of createrawtransaction" command. Do I get that right?

Not sure yet how to do all these things, but I will study and try it.
10  Bitcoin / Bitcoin Technical Support / bumpfee for transaction with specified changePosition on: July 06, 2021, 02:31:29 PM
Hi

To create a transaction with multiple outputs, I am using the command decoderawtransaction and fundrawtransaction with {changePosition} to have my change address as the last output in the list (this is important).

The transaction above is created as RBF. If I use the bumpfee command, the changeaddress gets randomly set in the output list.
How can I bump the fee of such a transaction and ensure the change position is still the last output of the transaction. Or is there a bumpfee command where I can specify the changePosition as in fundrawtransaction?

Running MacOs 11.4 and BitcoinCore 0.21.1
11  Bitcoin / Bitcoin Technical Support / Re: BitcoinCore: How to use bumpfee command the right way? on: July 05, 2021, 01:06:41 PM
I can confirm that both variations are working on my system

Code:
bitcoin-cli bumpfee "TXID" '{"fee_rate":20}'
AND
Code:
bitcoin-cli bumpfee "TXID" "{\"fee_rate\":20}"

Thanks for the support Smiley
12  Bitcoin / Bitcoin Technical Support / Re: BitcoinCore: How to use bumpfee command the right way? on: July 05, 2021, 11:14:38 AM
Tanks for all the replies! It makes sense that the error is coming from an incorrectly constructed json object.
I am using MacOS 11.4 and BitcoinCore 0.21.1.
So how do I use the options for a command on my system correctly?

Code:
bumpfee "TXID" '{"fee_rate":20}'
OR
Code:
bumpfee "TXID" "{\"fee_rate\":20}"

Thanks for your help
13  Bitcoin / Bitcoin Technical Support / BitcoinCore: How to use bumpfee command the right way? on: July 04, 2021, 07:00:35 PM
Hi

I created a transaction with the RBF option. Now I want to try the bumpfee command and set a specific fee.

./bitcoin-cli bumpfee "Txid" {"fee_rate":20}

but it throws an error: Error parsing JSON: {fee_rate:


Pleas help. How do I use the options of a bitcoin-cli command properly?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!