13 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 ...
user avatar
  • 63.4k
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): ...
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 ...
user avatar
  • 61.4k
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 ...
user avatar
  • 61.4k
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 ...
user avatar
  • 63.4k
5 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 ...
user avatar
  • 61.4k
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}]" "{\"...
user avatar
  • 28.7k
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 ...
user avatar
  • 5,006
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.
user avatar
  • 11.3k
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 ...
user avatar
  • 61.4k
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 ...
user avatar
  • 16.5k
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 ...
user avatar
  • 963
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
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 ...
user avatar
  • 1,530
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.
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\": \"...
user avatar
  • 1,101
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 ...
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 ...
user avatar
  • 1,530
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 ...
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 ...
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 ...
user avatar
  • 1,804
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 ...
user avatar
  • 2,702
2 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 ...
user avatar
  • 61.4k
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 ...
user avatar
  • 5,223
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 ...
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}]" "{\"...
user avatar
  • 61.4k
2 votes
Accepted

Calculate Miners Fee before Signing Raw Transaction?

Generally, you don't have to. The normal workflow is: Use listunspent to identify the outputs you want to use (if any). Use createrawtransaction to construct a raw transaction with the outputs you ...
user avatar
2 votes
Accepted

How to sign a raw multisig transaction from an external private key

The Bitcoin Wiki entry for OP_CHECKSIG answers your question. OP_CHECKMULTISIG works the same way, just applied to each signature in the sequence. First of all, it depends on the SIGHASH type you, as ...
user avatar
  • 4,676
2 votes
Accepted

Can't send raw transaction Bitcoin Core 0.19.1 - non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)

That error message is irrelevant. SegWit introduced a new way of producing the hash digest for signing which requires the "amount" being spent to be included during hashing. This "amount" is the value ...
user avatar
2 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 ...
user avatar

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