Struct Input
The input of the transaction, which spends a previously received Output
struct Input
;
Constructors
Name | Description |
---|---|
this
(utxo_, unlock, unlock_age)
|
Simple ctor |
this
(txhash, index, unlock_age)
|
Ctor which does hashing based on index |
this
(tx, index, unlock_age)
|
Ctor which does hashing based on the Transaction and index
|
this
(height)
|
Ctor to create dummy inputs for Coinbase TXs |
Fields
Name | Type | Description |
---|---|---|
unlock
|
Unlock | The unlock script, which will be ran together with the matching Input's lock script in the execution engine |
unlock_age
|
uint | The UTXO this Input references must be at least unlock_age older
than the block height at which the spending transaction wants to be
included in the block. Use for implementing relative time locks.
|
utxo
|
geod24 | The hash of the UTXO to be spent |
Methods
Name | Description |
---|---|
computeHash
(dg)
|
Implements hashing support |
opCmp
(rhs)
|
Support for sorting |
sizeInBytes
()
|
The size of the Input object |
Example
Transaction type serialize & deserialize for unittest
testSymmetry!Transaction();
Transaction payment_tx = Transaction(
[Input(Hash .init, 0)],
[Output(Amount(20), Lock .init)]
);
testSymmetry(payment_tx);
Transaction freeze_tx = Transaction(
[Input(Hash .init, 0)],
[Output(Amount(20), Lock .init, OutputType .Freeze)]
);
testSymmetry(freeze_tx);
Transaction data_tx = Transaction(
[Input(Hash .init, 0)],
[Output .init],
[1,2,3],
);
testSymmetry(data_tx);
Transaction cb_tx = Transaction(
[Input(Height(0))],
[Output(Amount(20), Lock .init, OutputType .Coinbase)]);
testSymmetry(cb_tx);
Example
Transaction type hashing for unittest
Transaction payment_tx = Transaction(
[Input(Hash .init, 0)],
[Output .init]
);
Transaction freeze_tx = Transaction(
[Input(Hash .init, 0)],
[Output(Amount(20), Lock .init, OutputType .Freeze)]
);
assert(payment_tx .hashFull() != freeze_tx .hashFull());