Signing Transactions
Signing Transactions in Bitcoin-S
There are two kinds of transaction signing in Bitcoin-S, as defined in Signer.scala
: Single Signing and Full Signing.
Single signing, which is implemented as a simple function in BitcoinSigner
, consists of using a single ECPrivateKey
(or other Sign implementation) to generate a PartialSignature
of the given transaction. This consists of an ECDigitalSignature
and a ECPublicKey
. This is useful any time you have a single private key and wish to get a single ECDigitalSignature
for that private key as is the case when using Partially Signed Bitcoin Transactions. In order to call signSingle
, you must have access to the unsigned transaction, as well as a ECSignatureParams
, which encapsulates all the information needed to sign with a single key. Note that if the unsigned transaction has signatures on it, they will be ignored.
Full signing, which is implemented by the subtypes of Signer
, consists of using any number of ECPrivateKey
s (or other Sign implementations) to generate a fully signed, TxSigComponent
for a given transaction. In order to call sign
on any instance of Signer
, you must have access to the unsigned transaction, as well as a ScriptSignatureParams
, which encapsulates all the information needed to sign with any number of keys. Note that the unsigned transaction can have signatures on it, just not on the input being signed. Specifically, a fully signed TxSigComponent
has a member called input
which will contain the fully signed TransactionInput
as well as scriptSignature
which contains the ScriptSignature
that was just generated. Additionally, TxSigComponent
has a member called transaction
which returns a transaction which has all inputs of the input unsigned transaction except for it uses the new input that was just generated by the call to sign
instead of an EmptyScriptSignature
.