crypto_wallet_util 2.0.4
crypto_wallet_util: ^2.0.4 copied to clipboard
A collection of utility functions for cryptocurrencies.
Changelog #
2.0.4 - 2026-08-02 #
Fixed #
- Raw ECDSA signatures now encode
randsto a fixed 32 bytes instead of copying the shortest big-endian encoding into a fixed-width buffer. A low-S value that fitted in 31 bytes previously threwBad state: Too few elementsand aborted signing. Low-S normalisation reducessinto[1, n/2], so this affected roughly 1 in 128 signatures; since a transaction signs once per input, multi-input DOGE/BTC/LTC/BCH transactions failed far more often than single-input sends. - PSBT and GSPL LTC Taproot signing use a real BIP341 TapSighash instead of
reusing the BIP143 SegWit v0 digest, and write the Schnorr signature to the
witness stack with an empty
scriptSiginstead of compiling it intoscriptSig. Verified against the official BIP341wallet-test-vectors.json. - PSBT Taproot re-signing preserves each input's original sequence instead of
resetting it to
0xffffffff, which silently dropped RBF and relative timelock semantics and invalidated the signature it had just produced. - Local BIP340 Schnorr signing encodes
t,P.x,R.x,sand the taproot tweak to a fixed 32 bytes, so a leading zero byte no longer corrupts the nonce/challenge hashes or yields a short signature or private key. - DOGE/LTC/BCH GSPL signing threads one explicit hashType through both the digest computation and the final signature encoding, so a non-default sighash no longer commits to one type while declaring another.
- Taproot sighash construction rejects unsupported hash types and
SIGHASH_SINGLEinputs without a corresponding output instead of producing a signature for an invalid BIP341 signing state. EthTxSigner.verify()interpretsvas a bare y-parity for typed (EIP-1559/EIP-7702) transactions and as EIP-155 only for legacy, and recovers the signer's address rather than checking structural bounds alone.isValidEthSignature()accepts scalars whose shortest encoding is under 32 bytes and rejectsr/sequal to the curve order, instead of the reverse.BtcCoin/LtcCoin/DogeCoin/BchCoin.verify(),PsbtTxSigner.verify(),GsplTxSigner.verify()andKasTxSigner.verify()perform real cryptographic verification over every input, replacing stubs that returnedtrueunconditionally or only checked that a signature field was present. Taproot verification checks against the tweaked output key, and non-Taproot verification parses DER plus the trailing sighash byte.- Legacy PSBT verification and finalization bind the serialized sighash suffix
to the digest being verified. Finalization also validates inputs backed by a
full previous transaction instead of skipping signature verification when
witnessUtxois absent. - PSBT DER-to-raw signature conversion re-encodes
randsto a fixed 32 bytes each, so a legitimately shortrno longer shiftssoff offset 32. DER parsing now rejects negative or excessively padded integers, values over 256 bits, inconsistent lengths and extra trailing data. DotCoin.verify()applies the same0x9cprefix stripping assign(), andprocessMessage()no longer throws on an empty message.- Schnorr aux randomness uses
Random.secure()over a full 32 bytes instead ofRandom()over 16 bytes zero-padded by the dependency. - secp256k1 private keys are validated (32 bytes, in
[1, n-1]) at theEcdaSignature.privateKeyToPublicKeyboundary shared by every secp256k1 wallet.
Changed #
- HNS transaction signing rejects inputs, outputs, address lengths and covenant fields that would require multi-byte varint encoding, instead of silently misparsing them. The full varint encoding is still unimplemented.
- The CKB single-lock-script-group assumption is now documented as a known
limitation:
CellInputcarries no lock-script data, so this class cannot detect or sign transactions spanning multiple script groups.
2.0.3 - 2026-07-17 #
Fixed #
- BTC address generation and validation now consistently honor the selected network, including legacy, SegWit v0, BIP86 Taproot, custom HRPs, and fail-closed handling for explicitly configured networks without a valid HRP.
- Taproot key tweaking now follows BIP341
lift_xsemantics and is pinned to the official BIP86 address and scriptPubKey vector. - Bech32, Bech32m, and CashAddr decoding now verifies checksum, network prefix, witness version and length, and canonical bit padding.
- BCH testnet uses
bchtestplus testnet version bytes, and BCH validation requires a full network-matching CashAddr to avoid BTC/BCH legacy ambiguity. - PSBT change detection infers the CashAddr network prefix from the input
address instead of hard-coding
bitcoincash, so BCH testnet CashAddr change outputs no longer abort transaction construction. PSBT.fromTransferPsbtselects the mainnet or testnet chain config from the extended key's BIP32 version bytes, so a standard testnettpub(0x043587cf) parses and builds instead of being rejected by the mainnet config and crashing on a null wallet. BTC/BCH testnet BIP32 public version bytes were corrected to0x043587cf.- BTC PSBT construction remains backward-compatible with the non-standard
testnet extended public-key version (
0x04358a68,tpw...) emitted by 2.0.2, while malformed keys and genuinely unknown versions now fail closed. - Taproot wallets keep the caller's
WalletSettingby reference and derive the BIP86 path at sign time, so switching the setting's network stays consistent across existing and freshly derived wallets.
2.0.2 - 2026-07-02 #
Fixed #
- PSBT: parse LTC P2SH / Nested SegWit addresses correctly by plumbing chain-aware version bytes and bech32 HRP through address encoding instead of hard-coding BTC mainnet values.
- GSPL: support LTC P2SH payment address parsing by detecting the script type (P2PKH vs P2SH) and resolving the correct network version bytes from the bip44 path coin-type segment.
- BTC / LTC chain configs: fill in distinct testnet NetworkType values (previously shared mainnet settings).
2.0.1 - 2026-06-12 #
Added #
- SC (Sia): native Go FFI transaction bridge (
ScGoFfiBridge) as a faster, opt-in alternative to the WASM bridge. The defaultcreate()is unchanged and still uses the WASM bridge (ScWasmRunBridge), so existing callers are unaffected. The native library is not bundled: the caller builds it for their platform (seelib/src/forked_lib/sia-wasi/build.sh), loads it, and passes it viaScTransactionBuilder.createWithFfi(DynamicLibrary).
Changed #
- Minimum Dart SDK raised to
>=3.11.0(required by thewasdWASM interpreter that backs the default SC bridge). Consumers on Dart 3.7–3.10 must upgrade.
Removed #
- Pruned dead code from the vendored
bitcoin_base_hdfork that is never reached by this package (BTC/LTC/BCH only useECPrivate):- the entire
provider/subtree (Electrum/HTTP API providers and theBitcoinTransactionBuilder/ BCH builder) andutils/btc_utils.dart(~2.2k lines). ECPublic.verifyTransactionSignatureandECPublic.verifySchnorrTransactionSignature(unused; their post-upgrade bodies had latent argument-shape issues).
- the entire
2.0.0 - 2026-06-09 #
BREAKING #
- Upgrade
blockchain_utilsfrom^1.4.1to^6.0.0. Resolves the dependency conflict reported in #20 (consumers usingbitcoin_base 7.x/xrpl_dart 7.x, which requireblockchain_utils ^6.0.0). - Minimum Dart SDK raised to
>=3.7.0(required byblockchain_utils 6.0.0).
Changed #
- Migrated the vendored
bitcoin_base_hdandxrpl_dartforks to theblockchain_utils6.x API: relocated utility imports to the package barrel,Tuple/item1,item2→ Dart records ($1,$2),mask*/writeUintXLE→BinaryOps.*,bytesEqual/iterableIsEqual→BytesUtils/CompareUtils,Secp256k1*KeyEcdsa→Secp256k1*Key,BitcoinSigner/BitcoinVerifier→BitcoinKeySigner/BitcoinSignatureVerifier,BigintUtils.orderLen→BigintUtils.bitlengthInBytes. - ECDSA / Taproot / message signing outputs verified byte-for-byte identical to the pre-upgrade implementation; XRP secp256k1 family-seed derivation and classic/X-address conversion pinned with characterization tests.
Bech32Validations/SegwitValidationsdeclared asmixin(Dart 3 language level no longer permits using a plain class as a mixin).
Notes #
- No public API changes beyond the SDK floor; all 782 unit tests pass.
1.0.0 - 2024-06-19 #
Added #
- Initial release version featuring fundamental functionalities:
- support wallets: ALPH, APTOS, CKB, COSMOS, DOT, HNS, KAS, KLS, NEAR, SC, SOL,SUI, XRP.
- support address check.
1.0.2 - 2024-07-30 #
Update #
- Add wallets: FIL, SCP.
- Add function: F410 address conversion, evm address custom generate.
1.0.5 - 2024-09-05 #
Update #
- Add wallet: ETH.
- Support eth transaction type: EIP1559, LEGACY.
- Support eth signed typed data module.