diff --git a/coinlib/lib/src/crypto/hash.dart b/coinlib/lib/src/crypto/hash.dart index 8b9d0f9..7c1e663 100644 --- a/coinlib/lib/src/crypto/hash.dart +++ b/coinlib/lib/src/crypto/hash.dart @@ -17,7 +17,7 @@ Uint8List hmacSha512(Uint8List key, Uint8List msg) => Uint8List.fromList( ); Uint8List Function(Uint8List msg) getTaggedHasher(String tag) { - final hashedTag = sha256Hash(utf8.encode(tag) as Uint8List); + final hashedTag = sha256Hash(utf8.encode(tag)); return (Uint8List msg) => sha256Hash( Uint8List.fromList([...hashedTag, ...hashedTag, ...msg]), ); diff --git a/coinlib/lib/src/crypto/hd_key.dart b/coinlib/lib/src/crypto/hd_key.dart index b661d75..c8653a1 100644 --- a/coinlib/lib/src/crypto/hd_key.dart +++ b/coinlib/lib/src/crypto/hd_key.dart @@ -231,16 +231,11 @@ class HDPrivateKey extends HDKey { HDPrivateKey({ required this.privateKey, - required Uint8List chaincode, - required int depth, - required int index, - required int parentFingerprint, - }) : super._( - chaincode: chaincode, - depth: depth, - index: index, - parentFingerprint: parentFingerprint, - ); + required super.chaincode, + required super.depth, + required super.index, + required super.parentFingerprint, + }) : super._(); /// Creates a master key from an existing private key and chain code. HDPrivateKey.fromKeyAndChainCode(this.privateKey, Uint8List chaincode) @@ -261,7 +256,7 @@ class HDPrivateKey extends HDKey { throw ArgumentError("Seed should be between 16 and 64 bytes", "seed"); } - final hash = hmacSha512(utf8.encode("Bitcoin seed") as Uint8List, seed); + final hash = hmacSha512(utf8.encode("Bitcoin seed"), seed); return HDPrivateKey( privateKey: ECPrivateKey(hash.sublist(0, 32)), chaincode: hash.sublist(32), @@ -308,16 +303,11 @@ class HDPublicKey extends HDKey { HDPublicKey({ required this.publicKey, - required Uint8List chaincode, - required int depth, - required int index, - required int parentFingerprint, - }) : super._( - chaincode: chaincode, - depth: depth, - index: index, - parentFingerprint: parentFingerprint, - ); + required super.chaincode, + required super.depth, + required super.index, + required super.parentFingerprint, + }) : super._(); /// Creates a HD public key from a base58 encoded representation ([b58]). May /// throw [InvalidBase58], [InvalidBase58Checksum] or [InvalidHDKey]. diff --git a/coinlib/lib/src/crypto/message_signature.dart b/coinlib/lib/src/crypto/message_signature.dart index 8e17e34..a62786f 100644 --- a/coinlib/lib/src/crypto/message_signature.dart +++ b/coinlib/lib/src/crypto/message_signature.dart @@ -15,7 +15,7 @@ class MagicHash with Writable { MagicHash(this.message, this.prefix); static _writeUtf8(Writer writer, String msg) - => writer.writeVarSlice(utf8.encode(msg) as Uint8List); + => writer.writeVarSlice(utf8.encode(msg)); @override void write(Writer writer) { diff --git a/coinlib/lib/src/crypto/nums_public_key.dart b/coinlib/lib/src/crypto/nums_public_key.dart index ddcdde2..58cf7be 100644 --- a/coinlib/lib/src/crypto/nums_public_key.dart +++ b/coinlib/lib/src/crypto/nums_public_key.dart @@ -20,8 +20,8 @@ class NUMSPublicKey extends ECPublicKey { final Uint8List _rTweak; - NUMSPublicKey._(Uint8List rTweak, Uint8List data) - : _rTweak = Uint8List.fromList(rTweak), super(data); + NUMSPublicKey._(Uint8List rTweak, super.data) + : _rTweak = Uint8List.fromList(rTweak), super(); /// Constructs a NUMS key from a given [rTweak]. /// Throws [ArgumentError] if [rTweak] cannot produce a valid public key. diff --git a/coinlib/lib/src/generated/secp256k1.ffi.g.dart b/coinlib/lib/src/generated/secp256k1.ffi.g.dart index 1172f6d..66110a0 100644 --- a/coinlib/lib/src/generated/secp256k1.ffi.g.dart +++ b/coinlib/lib/src/generated/secp256k1.ffi.g.dart @@ -2189,15 +2189,22 @@ typedef secp256k1_scratch_space = secp256k1_scratch_space_struct; /// /// Except for test cases, this function should compute some cryptographic hash of /// the message, the algorithm, the key and the attempt. -typedef secp256k1_nonce_function = ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer nonce32, - ffi.Pointer msg32, - ffi.Pointer key32, - ffi.Pointer algo16, - ffi.Pointer data, - ffi.UnsignedInt attempt)>>; +typedef secp256k1_nonce_function + = ffi.Pointer>; +typedef secp256k1_nonce_functionFunction = ffi.Int Function( + ffi.Pointer nonce32, + ffi.Pointer msg32, + ffi.Pointer key32, + ffi.Pointer algo16, + ffi.Pointer data, + ffi.UnsignedInt attempt); +typedef Dartsecp256k1_nonce_functionFunction = int Function( + ffi.Pointer nonce32, + ffi.Pointer msg32, + ffi.Pointer key32, + ffi.Pointer algo16, + ffi.Pointer data, + int attempt); /// Opaque data structured that holds a parsed ECDSA signature, /// supporting pubkey recovery. @@ -2268,17 +2275,26 @@ final class secp256k1_keypair extends ffi.Struct { /// /// Except for test cases, this function should compute some cryptographic hash of /// the message, the key, the pubkey, the algorithm description, and data. -typedef secp256k1_nonce_function_hardened = ffi.Pointer< - ffi.NativeFunction< - ffi.Int Function( - ffi.Pointer nonce32, - ffi.Pointer msg, - ffi.Size msglen, - ffi.Pointer key32, - ffi.Pointer xonly_pk32, - ffi.Pointer algo, - ffi.Size algolen, - ffi.Pointer data)>>; +typedef secp256k1_nonce_function_hardened = ffi + .Pointer>; +typedef secp256k1_nonce_function_hardenedFunction = ffi.Int Function( + ffi.Pointer nonce32, + ffi.Pointer msg, + ffi.Size msglen, + ffi.Pointer key32, + ffi.Pointer xonly_pk32, + ffi.Pointer algo, + ffi.Size algolen, + ffi.Pointer data); +typedef Dartsecp256k1_nonce_function_hardenedFunction = int Function( + ffi.Pointer nonce32, + ffi.Pointer msg, + int msglen, + ffi.Pointer key32, + ffi.Pointer xonly_pk32, + ffi.Pointer algo, + int algolen, + ffi.Pointer data); /// Data structure that contains additional arguments for schnorrsig_sign_custom. /// diff --git a/coinlib/lib/src/scripts/programs/p2tr.dart b/coinlib/lib/src/scripts/programs/p2tr.dart index ad348c8..2326e53 100644 --- a/coinlib/lib/src/scripts/programs/p2tr.dart +++ b/coinlib/lib/src/scripts/programs/p2tr.dart @@ -10,7 +10,7 @@ import 'package:coinlib/src/taproot.dart'; class P2TR extends P2Witness { /// Construct using an output script. - P2TR.fromScript(Script script) : super.fromScript(script) { + P2TR.fromScript(super.script) : super.fromScript() { if (data.length != 32 || version != 1) throw NoProgramMatch(); } diff --git a/coinlib/lib/src/scripts/programs/p2wpkh.dart b/coinlib/lib/src/scripts/programs/p2wpkh.dart index 53708d2..0c3c1e9 100644 --- a/coinlib/lib/src/scripts/programs/p2wpkh.dart +++ b/coinlib/lib/src/scripts/programs/p2wpkh.dart @@ -10,7 +10,7 @@ import 'package:coinlib/src/scripts/script.dart'; /// can satisfy this script with a signature provided as witness data. class P2WPKH extends P2Witness { - P2WPKH.fromScript(Script script) : super.fromScript(script) { + P2WPKH.fromScript(super.script) : super.fromScript() { if (data.length != 20 || version != 0) throw NoProgramMatch(); } diff --git a/coinlib/lib/src/scripts/programs/p2wsh.dart b/coinlib/lib/src/scripts/programs/p2wsh.dart index acd2fc5..589e6a5 100644 --- a/coinlib/lib/src/scripts/programs/p2wsh.dart +++ b/coinlib/lib/src/scripts/programs/p2wsh.dart @@ -12,7 +12,7 @@ class P2WSH extends P2Witness { /// Construct using an output script, not to be confused with the redeem /// script. For that use [fromRedeemScript]. - P2WSH.fromScript(Script script) : super.fromScript(script) { + P2WSH.fromScript(super.script) : super.fromScript() { if (data.length != 32 || version != 0) throw NoProgramMatch(); } diff --git a/coinlib/lib/src/tx/inputs/p2pkh_input.dart b/coinlib/lib/src/tx/inputs/p2pkh_input.dart index d9bbcf0..a961306 100644 --- a/coinlib/lib/src/tx/inputs/p2pkh_input.dart +++ b/coinlib/lib/src/tx/inputs/p2pkh_input.dart @@ -3,7 +3,6 @@ import 'package:coinlib/src/crypto/ec_public_key.dart'; import 'package:coinlib/src/scripts/operations.dart'; import 'package:coinlib/src/scripts/programs/p2pkh.dart'; import 'package:coinlib/src/scripts/script.dart'; -import 'package:coinlib/src/tx/outpoint.dart'; import 'package:coinlib/src/tx/sighash/sighash_type.dart'; import 'package:coinlib/src/tx/transaction.dart'; import 'input.dart'; @@ -27,17 +26,15 @@ class P2PKHInput extends LegacyInput with PKHInput { final int? signedSize = 147; P2PKHInput({ - required OutPoint prevOut, + required super.prevOut, required this.publicKey, this.insig, - int sequence = Input.sequenceFinal, + super.sequence = Input.sequenceFinal, }) : super( - prevOut: prevOut, scriptSig: Script([ if (insig != null) ScriptPushData(insig.bytes), ScriptPushData(publicKey.data), ]).compiled, - sequence: sequence, ); /// Checks if the [RawInput] matches the expected format for a [P2PKHInput], diff --git a/coinlib/lib/src/tx/inputs/p2sh_multisig_input.dart b/coinlib/lib/src/tx/inputs/p2sh_multisig_input.dart index 8493a95..9fb0759 100644 --- a/coinlib/lib/src/tx/inputs/p2sh_multisig_input.dart +++ b/coinlib/lib/src/tx/inputs/p2sh_multisig_input.dart @@ -6,7 +6,6 @@ import 'package:coinlib/src/scripts/operations.dart'; import 'package:coinlib/src/scripts/program.dart'; import 'package:coinlib/src/scripts/programs/multisig.dart'; import 'package:coinlib/src/scripts/script.dart'; -import 'package:coinlib/src/tx/outpoint.dart'; import 'package:coinlib/src/tx/sighash/legacy_signature_hasher.dart'; import 'package:coinlib/src/tx/sighash/sighash_type.dart'; import 'package:coinlib/src/tx/transaction.dart'; @@ -25,18 +24,16 @@ class P2SHMultisigInput extends LegacyInput { final List sigs; P2SHMultisigInput({ - required OutPoint prevOut, + required super.prevOut, required this.program, Iterable sigs = const [], - int sequence = Input.sequenceFinal, + super.sequence = Input.sequenceFinal, }) : sigs = List.unmodifiable(sigs), super( - prevOut: prevOut, scriptSig: Script([ ScriptOp.fromNumber(0), ...sigs.map((sig) => ScriptPushData(sig.bytes)), ScriptPushData(program.script.compiled), ]).compiled, - sequence: sequence, ) { if (sigs.length > program.threshold) { throw ArgumentError( diff --git a/coinlib/lib/src/tx/inputs/p2wpkh_input.dart b/coinlib/lib/src/tx/inputs/p2wpkh_input.dart index c00d64c..9f41e5b 100644 --- a/coinlib/lib/src/tx/inputs/p2wpkh_input.dart +++ b/coinlib/lib/src/tx/inputs/p2wpkh_input.dart @@ -1,7 +1,6 @@ import 'dart:typed_data'; import 'package:coinlib/src/crypto/ec_private_key.dart'; import 'package:coinlib/src/crypto/ec_public_key.dart'; -import 'package:coinlib/src/tx/outpoint.dart'; import 'package:coinlib/src/tx/sighash/sighash_type.dart'; import 'package:coinlib/src/tx/transaction.dart'; import 'input.dart'; @@ -26,13 +25,11 @@ class P2WPKHInput extends LegacyWitnessInput with PKHInput { final int? signedSize = 147; P2WPKHInput({ - required OutPoint prevOut, + required super.prevOut, required this.publicKey, this.insig, - int sequence = Input.sequenceFinal, + super.sequence = Input.sequenceFinal, }) : super( - prevOut: prevOut, - sequence: sequence, witness: [ if (insig != null) insig.bytes, publicKey.data, diff --git a/coinlib/lib/src/tx/inputs/taproot_key_input.dart b/coinlib/lib/src/tx/inputs/taproot_key_input.dart index 4408d00..4f4407c 100644 --- a/coinlib/lib/src/tx/inputs/taproot_key_input.dart +++ b/coinlib/lib/src/tx/inputs/taproot_key_input.dart @@ -3,7 +3,6 @@ import 'package:coinlib/src/crypto/ec_private_key.dart'; import 'package:coinlib/src/scripts/programs/p2tr.dart'; import 'package:coinlib/src/taproot.dart'; import 'package:coinlib/src/tx/inputs/taproot_input.dart'; -import 'package:coinlib/src/tx/outpoint.dart'; import 'package:coinlib/src/tx/output.dart'; import 'package:coinlib/src/tx/sighash/sighash_type.dart'; import 'package:coinlib/src/tx/transaction.dart'; @@ -21,14 +20,10 @@ class TaprootKeyInput extends TaprootInput { final int? signedSize = 41 + 65; TaprootKeyInput({ - required OutPoint prevOut, + required super.prevOut, this.insig, - int sequence = Input.sequenceFinal, - }) : super( - prevOut: prevOut, - sequence: sequence, - witness: [if (insig != null) insig.bytes], - ); + super.sequence = Input.sequenceFinal, + }) : super(witness: [if (insig != null) insig.bytes]); /// Checks if the [raw] input and [witness] data match the expected format for /// a [TaprootKeyInput], with a signature. If it does it returns a diff --git a/coinlib/lib/src/tx/inputs/taproot_script_input.dart b/coinlib/lib/src/tx/inputs/taproot_script_input.dart index 8072268..3c9eb4b 100644 --- a/coinlib/lib/src/tx/inputs/taproot_script_input.dart +++ b/coinlib/lib/src/tx/inputs/taproot_script_input.dart @@ -26,14 +26,12 @@ class TaprootScriptInput extends TaprootInput { final Script tapscript; TaprootScriptInput({ - required OutPoint prevOut, + required super.prevOut, required Uint8List controlBlock, required this.tapscript, List? stack, - int sequence = Input.sequenceFinal, + super.sequence = Input.sequenceFinal, }) : super( - prevOut: prevOut, - sequence: sequence, witness: [if (stack != null) ...stack, tapscript.compiled, controlBlock], ); diff --git a/coinlib/lib/src/tx/inputs/witness_input.dart b/coinlib/lib/src/tx/inputs/witness_input.dart index f2d6d27..a224010 100644 --- a/coinlib/lib/src/tx/inputs/witness_input.dart +++ b/coinlib/lib/src/tx/inputs/witness_input.dart @@ -1,5 +1,4 @@ import 'dart:typed_data'; -import 'package:coinlib/src/tx/outpoint.dart'; import 'input.dart'; import 'raw_input.dart'; import 'p2wpkh_input.dart'; @@ -12,14 +11,10 @@ class WitnessInput extends RawInput { final List witness; WitnessInput({ - required OutPoint prevOut, + required super.prevOut, required List witness, - int sequence = Input.sequenceFinal, - }) : witness = List.unmodifiable(witness), super( - prevOut: prevOut, - scriptSig: Uint8List(0), - sequence: sequence, - ); + super.sequence = Input.sequenceFinal, + }) : witness = List.unmodifiable(witness), super(scriptSig: Uint8List(0)); /// Matches a [raw] input with witness data to a corresponding [WitnessInput] /// or specialised sub-class object. If this is not a witness input, null is diff --git a/coinlib/pubspec.yaml b/coinlib/pubspec.yaml index d4b2922..68e72fd 100644 --- a/coinlib/pubspec.yaml +++ b/coinlib/pubspec.yaml @@ -6,11 +6,11 @@ version: 2.0.0-rc.1 repository: https://github.com/peercoin/coinlib environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.2.0 <4.0.0' dev_dependencies: - ffigen: ^9.0.1 - lints: ^2.0.0 + ffigen: ^10.0.0 + lints: ^3.0.0 test: ^1.21.0 dependencies: diff --git a/coinlib_flutter/example/pubspec.lock b/coinlib_flutter/example/pubspec.lock index ad34667..db40899 100644 --- a/coinlib_flutter/example/pubspec.lock +++ b/coinlib_flutter/example/pubspec.lock @@ -53,10 +53,10 @@ packages: dependency: transitive description: name: collection - sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687 + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a url: "https://pub.dev" source: hosted - version: "1.17.2" + version: "1.18.0" convert: dependency: transitive description: @@ -77,10 +77,10 @@ packages: dependency: "direct main" description: name: cupertino_icons - sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be + sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.0.6" dart_base_x: dependency: transitive description: @@ -114,10 +114,10 @@ packages: dependency: "direct dev" description: name: flutter_lints - sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4" + sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7 url: "https://pub.dev" source: hosted - version: "2.0.2" + version: "3.0.1" flutter_test: dependency: "direct dev" description: flutter @@ -143,10 +143,10 @@ packages: dependency: transitive description: name: lints - sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.0.0" matcher: dependency: transitive description: @@ -167,10 +167,10 @@ packages: dependency: transitive description: name: meta - sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3" + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.9.1" + version: "1.10.0" path: dependency: transitive description: @@ -183,10 +183,10 @@ packages: dependency: transitive description: name: plugin_platform_interface - sha256: "43798d895c929056255600343db8f049921cbec94d31ec87f1dc5c16c01935dd" + sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8 url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.1.7" pointycastle: dependency: transitive description: @@ -212,18 +212,18 @@ packages: dependency: transitive description: name: stack_trace - sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5 + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.11.1" stream_channel: dependency: transitive description: name: stream_channel - sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8" + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "2.1.2" string_scanner: dependency: transitive description: @@ -244,10 +244,10 @@ packages: dependency: transitive description: name: test_api - sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8" + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" url: "https://pub.dev" source: hosted - version: "0.6.0" + version: "0.6.1" typed_data: dependency: transitive description: @@ -276,10 +276,10 @@ packages: dependency: transitive description: name: web - sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10 + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.1.4-beta" + version: "0.3.0" sdks: - dart: ">=3.1.0-185.0.dev <4.0.0" + dart: ">=3.2.0 <4.0.0" flutter: ">=2.17.0" diff --git a/coinlib_flutter/example/pubspec.yaml b/coinlib_flutter/example/pubspec.yaml index d8a6164..64701f2 100644 --- a/coinlib_flutter/example/pubspec.yaml +++ b/coinlib_flutter/example/pubspec.yaml @@ -5,7 +5,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0 environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.2.0 <4.0.0' dependencies: flutter: @@ -16,7 +16,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 flutter: uses-material-design: true diff --git a/coinlib_flutter/pubspec.yaml b/coinlib_flutter/pubspec.yaml index 4d7d0bc..f905e7d 100644 --- a/coinlib_flutter/pubspec.yaml +++ b/coinlib_flutter/pubspec.yaml @@ -6,7 +6,7 @@ version: 2.0.0-rc.1 repository: https://github.com/peercoin/coinlib environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=3.2.0 <4.0.0' flutter: ">=2.17.0" dependencies: @@ -18,7 +18,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 flutter: plugin: