WIP (BlockchainLocal working)
Signed-off-by: James Zuccon <zuccon@gmail.com>
This commit is contained in:
@@ -106,4 +106,25 @@ export class Transaction {
|
||||
public getLocktime() {
|
||||
return this.transaction.locktime;
|
||||
}
|
||||
|
||||
public isCoinbase(): boolean {
|
||||
// TODO: This definitely needs checking.
|
||||
|
||||
// A coinbase transaction MUST only have one input.
|
||||
if (this.getInputs().length > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the input's unlocking bytecode.
|
||||
const unlockingBytecode = this.getInputs()[0].unlockingBytecode;
|
||||
|
||||
// Get the firt byte.
|
||||
const firstByte = unlockingBytecode[0];
|
||||
|
||||
if (firstByte >= 0x01 && firstByte <= 0x4b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user