The Stack Overflow podcast is back! Listen to an interview with our new CEO.
44

Addresses that start with 3... are P2SH addresses, and they've been around for almost 6 years now. Historically they saw limited use - used by multisig wallets like Copay and GreenAddress. The compatibility mode of SegWit however also uses P2SH, making their use more common recently. The main issue is that your code for converting an address to a ...


39

Step-by-step description: We start creating a new transaction which we hash and sign. Add four-byte version field: 01000000 One-byte varint specifying the number of inputs: 01 32-byte hash of the transaction from which we want to redeem an output (reverse order): be66e10da854e7aea9338c1f91cd489768d1d6d7189f586d7a3613f2a24d5396 Four-byte field denoting the ...


15

I found the way to do it, so, if anyone is interested, here is how to do it: When you have more than 1 input, you don't have to remove the inputs that you are not going to sign, you have to remove only their scripts. So, if you want to sign the transaction posted in the question, the first hash would be calculated like so: 'version': 1, 'inputs': (2) { ...


11

In case you have not seen it, there is a good (IMHO) article which describes how to generate a transaction "manually" using "raw" python (no bitcoin libs or RPC): "Bitcoins the hard way: Using the raw Bitcoin protocol"


11

From the Bitcoin forum: The way the variable length integer works is: Look at the first byte If that first byte is less than 253, use the byte literally If that first byte is 253, read the next two bytes as a little endian 16-bit number (total bytes read = 3) If that first byte is 254, read the next four bytes as a little endian 32-bit ...


9

Here: var bitcoin = require('bitcoinjs-lib') data = new Buffer("Melons.") var tx = new bitcoin.TransactionBuilder() tx.addInput("aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31", 0) tx.addOutput("some address", 15000) ret = bitcoin.script.compile( [ bitcoin.opcodes.OP_RETURN, data ]) tx.addOutput(ret, 0) key = bitcoin.ECPair....


9

Disclaimer: I am going to assume that you are not completely clueless and that you know what an array is, how to count from 0, and how to match brackets, quotes, and colons so that you can read JSON formatted data. If you don't know how to do those things, then please google them first before reading this post. Also, this post will be very long, and ...


8

Vitalik Buterin has recently shared Pybitcointools, a nice and simple-to-use Python library for handcrafting Bitcoin transactions. The example shows the basic workflow, which is pretty much what you have described in your example (just broken down to few more steps). If you need more help, this nice article explains bitcoin transactions technically and ...


8

You get this error because Bitcoin has tried to validate the script, and failed, because not all of the signatures necessary were added in the previous signrawtransaction. You can also tell this because complete is false. You need to take it to clients that have the other keys necessary, and run signrawtransaction on the transaction there too.


8

From Bitcoin Core's primitive/transaction.h: /** * Basic transaction serialization format: * - int32_t nVersion * - std::vector<CTxIn> vin * - std::vector<CTxOut> vout * - uint32_t nLockTime * * Extended transaction serialization format: * - int32_t nVersion * - unsigned char dummy = 0x00 * - unsigned char flags (!= 0) * - std::vector&...


7

I suspect that the second output is being rejected because it contains an OP_RETURN with two data pushes. From browsing the code, "Solver" in script.cpp only categorizes output scripts as "standard" if they meet one of a limited set of templates. All such templates containing OP_RETURN: OP_RETURN, by itself OP_RETURN, followed by a data push operation ...


7

This is specified thoroughly on the Bitcoin Wiki. The first 4 bytes are the version number, the next 1-9 bytes are the number of inputs (almost never more than 1 byte) and so on. Programitically, there are a ton of libraries that take the raw text and spit out the json as the bitcoin RPC call does in your example. They all use the same specification, ...


7

The only possibility in Bitcoin today is the one described by kaykurokawa. Every signature specifies which inputs and outputs it signs for, so if you want independently-created signatures, it will be obvious to everyone which input and output were created simultaneously. The general practice of combining multiple pieces of transactions into one is called ...


7

The bolded byte in the following raw transaction is the number of outputs (two in this transaction): ...


6

try this: bitcoind getrawtransaction 2f50fdf7adbf58e91d738869948f4b191eb3cafa016c6df7e9182c06e4513852 1 note the 1 at the end, which instructs bitcoind to operate in verbose mode.


6

What are the specific changes which have been made (ie relaxed standards)? Gavin Andresen made this pull request proposing the change, as well as this rationale document describing why he supported the change. Does it only apply to P2SH Txns? It applies only to P2SH redeem scripts, which is the script that is run to see if you have the data required to ...


6

OK, I figured out how to sign the raw Tx using Python ecdsa. I'll step through it: Recall: createrawtransaction '[{"txid" : "72b764383b99fb3d112ac8b474a5d7c4242b75dbfee2d4e9cf9a6703d90f805a", "vout" : 1}]' '{"n2kx7k6JuA5Wy27fawaeiPX7dq8mbRDPAv" : 0.99}' = ...


6

Yes. But they require the transaction to be signed a certain way. OP_CHECKSIG has settable flags, which determines which of the inputs and outputs are signed. If SIGHASH_SINGLE and SIGHASH_ANYONECANPAY is used for OP_CHECKSIG , each signature signs for its respective input and outputs, allowing others to add new inputs and outputs to the transaction. ...


6

This answer does not attempt to sign a transaction, but simply focuses on successfully calling the sign method of the ECKey class, i.e. making your code work. I am not yet familiar with the Transaction API of bitcoinj so I cannot go further than that. Your post suggests that your private key is given as a WiF so I have taken this as an assumption. The main ...


6

asm refers to the de-serialised form of the script, with well-known tokens parsed as script tokens. hex is just the serialised form of the script in hex encoding. If you compare them carefully, they are essentially equivalent. For example: OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG 76 a9 14 ...


6

The vout index (n) that you see after calling decoderawtransaction is added by bitcoind. It is not present in the raw transaction data. If you manually decode the serialized tx for your example, you get this for the output section: 02 # Number of outputs # value lockscript_length lockscript 005a620200000000 17 ...


6

Since it's an array, couldn't you just use the array index? Seems redundant, but i'm sure there's a reason. Thanks Yes, you could. In fact, that is how n is calculated since it isn't actually stored in the transaction. n is only provided as a convenience so that those constructing raw transactions do not need to count possibly hard to read JSON lines in ...


6

Addresses are associated with output scripts (scriptPubKeys). This information is not encoded in the transaction, the only information in the input is the txid and index of the output that is being redeemed. In order to do this offline you need to have the previous transaction. The way they do it for inputs is they look up the previous output that the ...


6

Can I send almost 1MB transaction? To be able to send a transaction that a miner will accept, that transaction has to be a standard transaction. As defined in policy.h /** The maximum weight for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000; For non-Segwit transactions, the limit is 400,000 KB / 4 = ...


5

That is correct. You create an additional txout with value 0 and script "OP_RETURN data".


5

That particular transaction is an attempt at something that has become known as "dust spam". The idea is that the sender sends a very small amount of bitcoin to many different addresses, hoping that people will notice and investigate further. It's possible to find out who sent this if you look hard enough, but most people won't bother. The effectiveness of ...


5

Old question, but answer might be helpful for someone. To get a raw transaction append: ?format=hex to the transaction URL. For example: https://blockchain.info/tx/1b087a7aebdd06740bd4ffefba076562b582a97f02cedf2cd32f53f7eb0b3c8c?format=hex


5

SX is a set of modular Bitcoin commandline utilities that admin types can engage with Bitcoin functionality without having to write code. http://sx.dyne.org http://bitcoinmagazine.com/6234/what-libbitcoin-and-sx-are-and-why-they-matter/ Using the Mycelium mobile app has to be the easiest method to spend funds from a paper wallet. From the app, select ...


5

Electrum has a gui form for just that. Also I think brainwallet.org has a web form that works offline and runs off github source directly so you can verify privacy concerns. Edit: also see: http://bitcointalk.org/index.php?topic=40264.msg851062#msg851062 As referenced in Transaction signature generation


5

There is a maximum standard transaction size since Bitcoin 0.8.2 of 100k per transaction. There are a number of other limits that influence the validation and propagation of a transaction though. Specifically: A block is limited to 20000 signature verifications. The block itself can't be larger than 1Mb. The standard Bitcoin client (Bitcoin Core / bitcoind)...


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