verify method
void
verify()
Implementation
void verify() {
// Basic checks that don't depend on any context
if (_txnInputs.isEmpty) {
throw VerificationException('transaction txins empty');
}
if (_txnOutputs.isEmpty) {
throw VerificationException('transaction txouts empty');
}
// Check for negative or overflow output values
var valueoutbn = BigInt.zero;
var ndx = 0;
for (var txout in _txnOutputs) {
if (txout.invalidSatoshis()) {
throw VerificationException('transaction txout $ndx satoshis is invalid');
}
if (txout.satoshis > Transaction.MAX_MONEY) {
throw VerificationException('transaction txout ${ndx} greater than MAX_MONEY');
}
valueoutbn = valueoutbn + txout.satoshis;
if (valueoutbn > Transaction.MAX_MONEY) {
throw VerificationException('transaction txout ${ndx} total output greater than MAX_MONEY');
}
}
// Size limits
if (serialize().length > MAX_BLOCK_SIZE) {
throw VerificationException('transaction over the maximum block size');
}
// Check for duplicate inputs
var txinmap = {};
for (var i = 0; i < inputs.length; i++) {
var txin = inputs[i];
var inputid = txin.prevTxnId + ':' + txin.prevTxnOutputIndex.toString();
if (txinmap[inputid] != null) {
throw VerificationException('transaction input ' + i.toString() + ' duplicate input');
}
txinmap[inputid] = true;
}
if (isCoinbase()) {
var script = inputs[0].script ??= SVScript();
var buf = script.buffer;
if (buf.length < 2 || buf.length > 100) {
throw VerificationException('coinbase transaction script size invalid');
}
} else {
for (TransactionInput input in inputs) {
if (input == null || input.isCoinBase()) {
throw VerificationException("transaction input has null input");
}
}
}
}