16 votes
Accepted

What's the most efficient way to create a raw transaction with a specific fee rate?

Yes! The trick is to count each input with its effective value rather than its nominal value. Transactions are composed of three parts: the overhead, the inputs and the outputs. Outputs: The size of ...
Murch's user avatar
  • 72.9k
8 votes
Accepted

Breaking down a raw transaction:

The bolded byte in the following raw transaction is the number of outputs (two in this transaction): ...
David A. Harding's user avatar
8 votes
Accepted

How to disable RBF in Bitcoin Core?

walletrbf=0 only disables RBF when creating transactions through wallet RPCs such as sendtoaddress, sendmany or sendall. If you use the low-level RPC createrawtransaction, you need to either set the ...
Vojtěch Strnad's user avatar
7 votes

What does "operation not valid with the current stack size" mean?

The signrawtransaction RPC will verify the input scripts of the transaction after it signs it. If the transaction has not been fully signed (i.e. it isn't complete), then the script verification will ...
Andrew Chow's user avatar
  • 68.6k
6 votes

What's the most efficient way to create a raw transaction with a specific fee rate?

Kind of, but coin selection is hard in general. The idea is that inputs pay for themselves. It is easy to compute how much in fees you will need to pay for an input at a given fee rate. So when you do ...
Andrew Chow's user avatar
  • 68.6k
6 votes
Accepted

Function combinerawtransaction is not working

The issue here is that the two transactions are different, and combinerawtransaction does not operate on different transactions (it apparently just silently does nothing). It sounds like you expect ...
Andrew Chow's user avatar
  • 68.6k
5 votes

bitcoin-cli commands like createrawtransaction not working with json on command line

When looking at the Bitcoin Developer Reference I saw an example where they use two additional '' before and after the list of inputs in comparison to you. For your input, I also got "Error parsing ...
Murch's user avatar
  • 72.9k
4 votes

bitcoin-cli commands like createrawtransaction not working with json on command line

Try rewriting your command to bitcoin-cli -testnet createrawtransaction "[{\"txid\": \"12b8e7ede4992f4d30f93idj3085746951d945e39f40becebd7c290af8c2e7ad\", \"vout\": 0}]" "{\"...
Nick ODell's user avatar
  • 29.3k
4 votes
Accepted

Create a raw transaction and broadcast it to blockchain using bitcoin core

EDIT: based on OPs request, I put examples in here: there are a lot of examples for different tx types on bitcoin.org, in the developer examples. Basically you will need three steps. Assuming you are ...
pebwindkraft's user avatar
  • 5,086
4 votes

Values for txid and vout for create a coinbase transaction

The coinbase transaction contains a single input, which has txid set to 0000000000000000000000000000000000000000000000000000000000000000 and vout set to 0xFFFFFFFF.
meshcollider's user avatar
  • 11.8k
4 votes

How to recover and sweep P2PK coins

You can achieve this without any script, simply using the Bitcoin Core wallet. For each public key you received funds on you can import a pk() descriptor containing the corresponding private key, WIF-...
Antoine Poinsot's user avatar
3 votes

Error in creating bitcoin raw transaction

You provided the amount incorrectly. The amount is 0.54551 not 545500. This is important as Segwit inputs include the previous output's amount in the signature. Providing the wrong amount will result ...
Andrew Chow's user avatar
  • 68.6k
3 votes
Accepted

bitcoin-cli createrawtransaction and purpose of "scriptPubKey"?

Currently, the create raw transaction method only uses the txid and vout parameters from that argument. You can view the relevant part of the source here. For all practical purposes, you could pass in ...
Raghav Sood's user avatar
  • 16.9k
3 votes
Accepted

Is there a way to create coinbase transactions with an RPC command?

Yep, it is partially possible with the getblocktemplate RPC command. This is what miners routinely use to obtain the information necessary to begin mining a block. The exact parameters and response ...
Mason Ticehurst's user avatar
3 votes
Accepted

How to push a raw transaction using BitcoinJS (and Request)?

Body must be a string. You can use form instead of body. Reference: https://www.npmjs.com/package/request#forms
siddolo's user avatar
  • 46
3 votes
Accepted

Unable to create raw transaction with json-rpc command

Here is the correct json: createrawtransaction '[{"txid":"0000000000000000000000000000000000000000000000000000000000000000","vout":0}]' '{"1Ka3q3DVTBNBo2c4kVGMNzbd32RARV1FbA":12.5}' I used 0for ...
Albert S's user avatar
  • 1,630
3 votes
Accepted

64: non-mandatory-script-verify-flag while broadcasting P2WPKH Bech32 with specific inputs

First of all, these are not P2SH-P2WPKH, these are normal P2WPKH outputs. They are not related to P2SH at all. The problem here is probably that the amount is incorrect. If you are providing the ...
Andrew Chow's user avatar
  • 68.6k
3 votes

When and where to add extra information when signing P2SH raw transaction?

Bitcoin Core's signrawtransaction RPC does not know about the specific type of script you're trying to sign for, and won't be usable. You'll need to implement the signing logic yourself.
Pieter Wuille's user avatar
3 votes

What does "operation not valid with the current stack size" mean?

I have faced the same issue i was trying to creat a raw transaction with erronerous Vout (1 instead 0) bitcoin-cli createrawtransaction "[{\"txid\": \"...
Badr Bellaj's user avatar
  • 1,141
3 votes

How to send bitcoins with commission extracted from payment in PHP or bitcoind

Here is the algorythm without the code: createrawtransaction with amount that you want to send assuming that fees are 0 fundrawtransaction to let your bitcoind construct final transaction, put your ...
Denis Matafonov's user avatar
3 votes
Accepted

Create raw transaction what txid

In the console do listunspent that will show you all the UTXO in your wallet including the txids. You can type help to get a list of commands, then help <command> to get details about each ...
Albert S's user avatar
  • 1,630
3 votes
Accepted

Bitcoin-cli how to createrawtransaction without spending entire input?

Is there any possible way to create a raw transaction using Bitcoin-cli createrawtransaction API that doesn't require spending the entire input? No. It's an inherent feature of the Bitcoin protocol ...
Nate Eldredge's user avatar
3 votes
Accepted

What "Data" should be inserted into the argument field of the "createrawtransaction" rpc command

The data field is only for when you want to create data-carrying transactions (ones with an OP_RETURN). This is generally not needed in normal transactions (and its usage there is somewhat ...
Pieter Wuille's user avatar
3 votes

json parsing error with createrawtransaction with bitcoin-cli in regtest

Using quotes and escaping like this should work on Windows: createrawtransaction "[{\"txid\":\"7b2d65b85487a891a3e0a9c541975fa7e681e571ea18982da49402e594ca2af1\",\"vout\&...
Vojtěch Strnad's user avatar
2 votes
Accepted

How to estimate mining fee for raw transaction?

Have a look at fundrawtransaction (if you are okay using the internal wallet). fundrawtransaction will give you back the used fee (next to the hex byte-array of the funded transaction) before signing ...
Jonas Schnelli's user avatar
2 votes
Accepted

createrawtransaction and fundrawtransaction

There are many more parameters than number of confirmations for input selection. It mainly depends on the amounts used in the outputs because eventually enough inputs have to be used to cover the ...
arubi's user avatar
  • 1,854
2 votes
Accepted

Why do I get 5 bytes worth of 0x00 hex values in both outputs?

The value of an output in a transaction is a 8-byte field encoded in little-endian. The value is always represented with 8 bytes no matter how small it is. Here you have the full transaction structure ...
sr_gi's user avatar
  • 3,192
2 votes
Accepted

bitcoin rpc api createrawtransaction with python returns -3: Expected type array, got object

You are providing it an Object in JSON, not an array just as the error states. return {"txid": sourcetransaction['txid'] ,"vout":sourcetransaction['vout']} I would try creating it from a ...
m1xolyd1an's user avatar
  • 5,596
2 votes
Accepted

Bitcoin-cli createrawtransaction with 3 outputs example

You need to use (simplified notation) [{addr:amount},{addr:amount}] for the outputs, not [{addr:amount,addr:amount}]. This is to permit multiple outputs with the same address (which wouldn't be valid ...
Pieter Wuille's user avatar
2 votes

The nlocktime parameter in createrawtransaction seems not work using Bitcoin Core Wallet GUI

You're putting the locktime in the wrong place. You have "[{\"txid\":\"myid\",\"vout\":0}]" "{\"address\":0.01, \"address\":0.01} 20" but it should really be "[{\"txid\":\"myid\",\"vout\":0}]" "{\"...
Andrew Chow's user avatar
  • 68.6k

Only top scored, non community-wiki answers of a minimum length are eligible