diff --git a/coinlib/lib/src/crypto/hd_key.dart b/coinlib/lib/src/crypto/hd_key.dart index 9bc2fad..b661d75 100644 --- a/coinlib/lib/src/crypto/hd_key.dart +++ b/coinlib/lib/src/crypto/hd_key.dart @@ -12,9 +12,9 @@ class InvalidHDKeyVersion implements Exception {} abstract class HDKey { - static int maxIndex = 0xffffffff; - static int hardenBit = 0x80000000; - static int encodedLength = 78; + static const maxIndex = 0xffffffff; + static const hardenBit = 0x80000000; + static const encodedLength = 78; final Uint8List _chaincode; final int depth; diff --git a/coinlib/lib/src/encode/bech32.dart b/coinlib/lib/src/encode/bech32.dart index 2f12f1c..a525277 100644 --- a/coinlib/lib/src/encode/bech32.dart +++ b/coinlib/lib/src/encode/bech32.dart @@ -81,10 +81,10 @@ enum Bech32Type { bech32, bech32m } /// words may need to be further converted into the required data. class Bech32 { - static int maxLength = 90; - static int checksumLength = 6; - static int bech32CheckConst = 1; - static int bech32mCheckConst = 0x2bc830a3; + static const maxLength = 90; + static const checksumLength = 6; + static const bech32CheckConst = 1; + static const bech32mCheckConst = 0x2bc830a3; final String hrp; final List words; diff --git a/coinlib/lib/src/scripts/operations.dart b/coinlib/lib/src/scripts/operations.dart index e557d51..670d3e3 100644 --- a/coinlib/lib/src/scripts/operations.dart +++ b/coinlib/lib/src/scripts/operations.dart @@ -12,13 +12,12 @@ class PushDataNotMinimal implements Exception {} /// Represents a single operation or script pushdata abstract class ScriptOp { - static int op1Negate = scriptOpNameToCode["1NEGATE"]!; - static int op1 = scriptOpNameToCode["1"]!; - static int op16 = scriptOpNameToCode["16"]!; - static int pushData1 = scriptOpNameToCode["PUSHDATA1"]!; - static int pushData2 = pushData1+1; - static int pushData4 = pushData2+1; - + static final op1Negate = scriptOpNameToCode["1NEGATE"]!; + static final op1 = scriptOpNameToCode["1"]!; + static final op16 = scriptOpNameToCode["16"]!; + static final pushData1 = scriptOpNameToCode["PUSHDATA1"]!; + static final pushData2 = pushData1+1; + static final pushData4 = pushData2+1; static final pushdataMatcherRegExp = RegExp(r"^<(\d+)-bytes>$"); /// The compiled bytes for this operation diff --git a/coinlib/lib/src/scripts/programs/multisig.dart b/coinlib/lib/src/scripts/programs/multisig.dart index f2abb85..b1e0d62 100644 --- a/coinlib/lib/src/scripts/programs/multisig.dart +++ b/coinlib/lib/src/scripts/programs/multisig.dart @@ -6,8 +6,8 @@ import 'package:coinlib/src/scripts/script.dart'; class MultisigProgram implements Program { - static int maxPubkeys = 20; - static ScriptOp checkmultisig = ScriptOpCode.fromName("CHECKMULTISIG"); + static const maxPubkeys = 20; + static final checkmultisig = ScriptOpCode.fromName("CHECKMULTISIG"); @override final Script script; diff --git a/coinlib/lib/src/scripts/programs/p2pkh.dart b/coinlib/lib/src/scripts/programs/p2pkh.dart index 7b71e6b..320ee6f 100644 --- a/coinlib/lib/src/scripts/programs/p2pkh.dart +++ b/coinlib/lib/src/scripts/programs/p2pkh.dart @@ -10,7 +10,7 @@ import 'package:coinlib/src/scripts/script.dart'; /// satisfy this script with a signature. class P2PKH implements Program { - static Script template = Script.fromAsm( + static final template = Script.fromAsm( "OP_DUP OP_HASH160 <20-bytes> OP_EQUALVERIFY OP_CHECKSIG", ); diff --git a/coinlib/lib/src/scripts/programs/p2sh.dart b/coinlib/lib/src/scripts/programs/p2sh.dart index 68ca998..90a713b 100644 --- a/coinlib/lib/src/scripts/programs/p2sh.dart +++ b/coinlib/lib/src/scripts/programs/p2sh.dart @@ -8,7 +8,7 @@ import 'package:coinlib/src/scripts/script.dart'; /// Pay-to-Script-Hash program taking a 20-byte script hash for a redeem script. class P2SH implements Program { - static Script template = Script.fromAsm("OP_HASH160 <20-bytes> OP_EQUAL"); + static final template = Script.fromAsm("OP_HASH160 <20-bytes> OP_EQUAL"); @override final Script script; diff --git a/coinlib/lib/src/tx/output.dart b/coinlib/lib/src/tx/output.dart index f86a587..20eec2f 100644 --- a/coinlib/lib/src/tx/output.dart +++ b/coinlib/lib/src/tx/output.dart @@ -10,7 +10,7 @@ import 'package:coinlib/src/scripts/script.dart'; class Output with Writable { /// Max 64-bit integer - static BigInt maxValue = (BigInt.from(1) << 64) - BigInt.one; + static final maxValue = (BigInt.from(1) << 64) - BigInt.one; final BigInt value; final Uint8List _scriptPubKey; diff --git a/coinlib/lib/src/tx/sighash_type.dart b/coinlib/lib/src/tx/sighash_type.dart index 1572960..05863eb 100644 --- a/coinlib/lib/src/tx/sighash_type.dart +++ b/coinlib/lib/src/tx/sighash_type.dart @@ -5,14 +5,14 @@ class SigHashType { /// Value to sign all outputs - static const int allValue = 1; + static const allValue = 1; /// Value to sign no outputs - static const int noneValue = 2; + static const noneValue = 2; /// Value to sign the output at the same index as the input - static const int singleValue = 3; + static const singleValue = 3; /// Flag that can be combined with other hash type values to only sign the /// input containing the signature - static const int anyOneCanPayFlag = 0x80; + static const anyOneCanPayFlag = 0x80; /// The single byte representation of the sighash type. Use [all], [none], /// [single] and [anyonecanpay] to extract details of the type. diff --git a/coinlib/lib/src/tx/transaction.dart b/coinlib/lib/src/tx/transaction.dart index 7048603..44ca4a6 100644 --- a/coinlib/lib/src/tx/transaction.dart +++ b/coinlib/lib/src/tx/transaction.dart @@ -31,19 +31,19 @@ class CannotSignInput implements Exception { /// with witness data. class Transaction with Writable { - static Uint8List hashZero = Uint8List(32); - static Uint8List hashOne = Uint8List(32)..last = 1; + static final hashZero = Uint8List(32); + static final hashOne = Uint8List(32)..last = 1; - static const int currentVersion = 3; - static const int maxSize = 1000000; + static const currentVersion = 3; + static const maxSize = 1000000; - static const int minInputSize = 41; - static const int minOutputSize = 9; - static const int minOtherSize = 10; + static const minInputSize = 41; + static const minOutputSize = 9; + static const minOtherSize = 10; - static const int maxInputs + static const maxInputs = (maxSize - minOtherSize - minOutputSize) ~/ minInputSize; - static const int maxOutputs + static const maxOutputs = (maxSize - minOtherSize - minInputSize) ~/ minOutputSize; final int version;