Transaction class
Allows construction and signing of Peercoin transactions including those with witness data.
- Mixed-in types
Constructors
-
Transaction({int version = currentVersion, required Iterable<
Input> inputs, required Iterable<Output> outputs, int locktime = 0}) -
Constructs a transaction with the given
inputs
andoutputs
. TransactionTooLarge will be thrown if the resulting transction exceeds maxSize (1MB). - Transaction.fromBytes(Uint8List bytes, {bool? expectWitness})
-
Constructs a transaction from serialised bytes. See fromReader().
factory
- Transaction.fromHex(String hex, {bool? expectWitness})
-
Constructs a transaction from the serialised data encoded as hex. See
fromReader().
factory
- Transaction.fromReader(BytesReader reader, {bool? expectWitness})
-
Reads a transaction from a BytesReader, which may throw
TransactionTooLarge or InvalidTransaction if the data doesn't
represent a complete transaction within maxSize (1MB).
If
expectWitness
is true, the transaction is assumed to be a witness transaction. If it is false, the transction is assumed to be a legacy non-witness transaction. IfexpectWitness
is omitted or null, then this method will determine the correct transaction type from the data, starting with a witness type.factory
Properties
- complete → bool
-
Returns true when all of the inputs are fully signed with at least one
input and one output. There is no guarentee that the transaction is valid
on the blockchain.
no setter
- hash → Uint8List
-
The serialized tx data hashed with sha256d
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hashHex → String
-
Get the reversed hash as hex which is usual for Peercoin transactions
This provides the witness txid. See legacyHash for the legacy type of
hash.
no setter
-
inputs
→ List<
Input> -
final
- isCoinBase → bool
-
no setter
- isCoinStake → bool
-
no setter
- isWitness → bool
-
If the transaction has any witness inputs.
no setter
- legacy → Transaction
-
Returns a non-witness variant of this transaction. Any witness inputs are
replaced with their raw equivalents without witness data. If the
transaction is already non-witness, then it shall be returned as-is.
no setter
- legacyHash → Uint8List
-
The serialized tx data without witness data hashed with sha256d
no setter
- locktime → int
-
final
-
outputs
→ List<
Output> -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- size → int
-
Obtains the cached size of the object
no setterinherited
- txid → String
-
Gets the legacy reversed hash as hex without witness data.
no setter
- version → int
-
final
Methods
-
addInput(
Input input) → Transaction -
Returns a new Transaction with the
input
added to the end of the input list. -
addOutput(
Output output) → Transaction -
Returns a new Transaction with the
output
added to the end of the output list. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
replaceInput(
Input input, int n) → Transaction -
Replaces the input at
n
with the newinput
and invalidates other input signatures that have standard sighash types accordingly. This is useful for signing or otherwise updating inputs that cannot be signed with the sign method. -
sign(
{required int inputN, required ECPrivateKey key, SigHashType hashType = const SigHashType.all(), BigInt? value, List< Output> ? prevOuts}) → Transaction -
Sign the input at
inputN
with thekey
andhashType
and return a new Transaction with the signed input. The input must be a signable P2PKHInput, P2WPKHInput, P2SHMultisigInput or TaprootKeyInput. Otherwise CannotSignInput will be thrown. Other inputs may be signed seperately and inserted back into the transaction via replaceInput.value
is only required for P2WPKH.prevOuts
is only required for Taproot inputs. -
toBytes(
) → Uint8List -
Obtains a cached Uint8List with data serialized for this object
inherited
-
toHex(
) → String -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
write(
Writer writer) → void -
Override to write data into
writer
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- currentVersion → const int
- maxInputs → const int
- maxOutputs → const int
- maxSize → const int
- minInputSize → const int
- minOtherSize → const int
- minOutputSize → const int