public class TransactionSignature extends ECKey.ECDSASignature
ECKey.ECDSASignature
and adds methods for handling
the additional SIGHASH mode byte that is used.Modifier and Type | Field and Description |
---|---|
int |
sighashFlags
A byte that controls which parts of a transaction are signed.
|
r, s
Constructor and Description |
---|
TransactionSignature(java.math.BigInteger r,
java.math.BigInteger s)
Constructs a signature with the given components and SIGHASH_ALL.
|
TransactionSignature(java.math.BigInteger r,
java.math.BigInteger s,
int sighashFlags)
Constructs a signature with the given components and raw sighash flag bytes (needed for rule compatibility).
|
TransactionSignature(ECKey.ECDSASignature signature,
Transaction.SigHash mode,
boolean anyoneCanPay)
Constructs a transaction signature based on the ECDSA signature.
|
Modifier and Type | Method and Description |
---|---|
boolean |
anyoneCanPay() |
static int |
calcSigHashValue(Transaction.SigHash mode,
boolean anyoneCanPay)
Calculates the byte used in the protocol to represent the combination of mode and anyoneCanPay.
|
static TransactionSignature |
decodeFromBitcoin(byte[] bytes,
boolean requireCanonicalEncoding,
boolean requireCanonicalSValue)
Returns a decoded signature.
|
static TransactionSignature |
dummy()
Returns a dummy invalid signature whose R/S values are set such that they will take up the same number of
encoded bytes as a real signature.
|
byte[] |
encodeToBitcoin()
What we get back from the signer are the two components of a signature, r and s.
|
static boolean |
isEncodingCanonical(byte[] signature)
Returns true if the given signature is has canonical encoding, and will thus be accepted as standard by
Bitcoin Core.
|
Transaction.SigHash |
sigHashMode() |
ECKey.ECDSASignature |
toCanonicalised()
Will automatically adjust the S component to be less than or equal to half the curve order, if necessary.
|
decodeFromDER, derByteStream, encodeToDER, equals, hashCode, isCanonical
public final int sighashFlags
public TransactionSignature(java.math.BigInteger r, java.math.BigInteger s)
public TransactionSignature(java.math.BigInteger r, java.math.BigInteger s, int sighashFlags)
public TransactionSignature(ECKey.ECDSASignature signature, Transaction.SigHash mode, boolean anyoneCanPay)
public static TransactionSignature dummy()
public static int calcSigHashValue(Transaction.SigHash mode, boolean anyoneCanPay)
public static boolean isEncodingCanonical(byte[] signature)
public boolean anyoneCanPay()
public Transaction.SigHash sigHashMode()
public byte[] encodeToBitcoin()
public ECKey.ECDSASignature toCanonicalised()
ECKey.ECDSASignature
toCanonicalised
in class ECKey.ECDSASignature
public static TransactionSignature decodeFromBitcoin(byte[] bytes, boolean requireCanonicalEncoding, boolean requireCanonicalSValue) throws SignatureDecodeException, VerificationException
requireCanonicalEncoding
- if the encoding of the signature must
be canonical.requireCanonicalSValue
- if the S-value must be canonical (below half
the order of the curve).SignatureDecodeException
- if the signature is unparseable in some way.VerificationException
- if the signature is invalid.