In order to add convenience methods to a transaction, such as pushing new
inputs and outputs, we need to first have the notion of an initialized
transaction, which is actually not blank. An initialized transaction just has
default values for everything, such as no inputs and no outputs, and default
version and nlocktime.
Script().writeOp('OP_CHECKMULTISIG'), or...
Script().writeOp(174), or...
Script().writeBuffer([push data buffer]), or...
Script().write([op string, number, or push data buffer])
These convenience methods let you easily write a script.
For spotting transactions to which you have the stealth key (or at least the
scan key) and creating transactions to a stealth address. So far it is only
partially working - you can see if a transaction is a stealth transaction (or
at least one of a limited kind of stealth transactions), and you can see that
you do not have the stealth key to spend one of these transactions. However, I
have not yet tested whether you can see a stealth transaction that you actually
have the key to. Also, it is not yet easy to spend to a stealth address.
These functions are prefixed DW which stands for Dark Wallet. The code for the
Dark Wallet address format can be found here:
https://github.com/darkwallet/darkwallet/blob/develop/js/util/stealth.js
Note that I deliberately support only the simplest possible format, which is
where there is only one payload pubkey and the prefix is blank. I should now go
back and replace my old toString, fromString, toBuffer, fromBuffer functions
with these Dark Wallet versions, since they are much more well-thought out than
mine.
For Transaction, Block and Blockheader. This is a convenience so if you happen
to have the buffer for one of these, you can make a new one like this:
Transaction(txbuf);
Rather than having to do this:
Transaction().fromBuffer(txbuf);
I had been using this formula for the receiveKeypair:
scanKeypair + payloadKeypair + sharedKeypair
However, Dark Wallet uses this formula:
payloadKeypair + sharedKeypair
It is not actually necessary to add the scanKeypair in order to have all the
features of stealth addresses, at least as far as I can tell. So in order to
bring my implementation closer to Dark Wallet's, I have removed the scanKeypair
from this calculation.
bitcoind saves blocks in files called blk*****.dat. Those files can be piped
into this example, which will parse them and spit out a nice looking string of
all the blocks, which also includes parsed transactions.