A Transaction (and its subsequent scripts) do not carry any network
specific information in the Bitcoin protocol.
Therefore they can not (without further context) produce the network
specific constants for the generation of the base58 Addresses.
As TransactionOut.address is used heavily throughout Wallet and other
areas of the library, this could not be entirely removed without a large
number of changes.
For now, TransactionOut.address is only defined in the case of
Tx.addOutput being used directly:
Transaction.addOutput(address, value)
The introduction of these two functions allow for the all the network
related code to be eventually removed from Transaction and Script.
Previously the result for non-standard transactions was undefined
behaviour. This change mandates that an exception is thrown if a
non-standard transaction is input.
Extracts the two Script types out of Script.createOutputScript, and puts
them both under test.
Also renames Script.createMultiSigOutputScript to adhere to the same
convention.
Script.fromHex previously existed, but was not under any kind of test.
This commit adds tests (despite being a little circular in nature) to
check that the output is as expected.
These functions are not under test, and are unnecessary bloat due to a
confusing API.
Script.from*(asmStr) were two functions that attempted to parse ASM
codes and produce a script from this.
While useful, an parser can be introduced later under a single function
and under test... removed.
Although Script.extractPublicKeys implementation is likely to be correct,
it is not absolute in that what it returns is even strictly a set of
public keys.
It is a useful function, but can be done in a better way later,
probably checking against the Script templates instead.
Transaction.signWithKeys has some inherent undocumented behaviour, and it is not
clear when you would use it over just Transaction.addOutput and
Transaction.sign individually. Nor does it mimic anything in the
bitcoind API... removed.
To keep this change minimal, both TxIn/TxOut still use the parameter
object for initialization. TxOut accepts only the types it uses
internally, and not hex or byte arrays for scripts.
The clone is unnecessary as a TransactionOut is never mutated after its
creation.
This resulted in TransactionOut.scriptPubKey no longer being needed,
and was removed. To access the scriptPubKey as a byte buffer, a user
can simply use:
TransactionOut.script.toBuffer()
Unfortunately, this leaves TransactionOut in a sorry state of test.
Something that needs to be fixed.