From b909c72cb91d5488de8b9efb8a1b58d1efdc47cd Mon Sep 17 00:00:00 2001 From: sneurlax Date: Tue, 4 Jun 2024 18:32:12 -0500 Subject: [PATCH 1/4] add and use transactionVersion property for peercoin TODO add versions for the rest of the coins --- lib/wallets/crypto_currency/coins/peercoin.dart | 3 +++ .../interfaces/electrumx_currency_interface.dart | 2 +- .../wallet/wallet_mixin_interfaces/electrumx_interface.dart | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/wallets/crypto_currency/coins/peercoin.dart b/lib/wallets/crypto_currency/coins/peercoin.dart index 0edc1cbfa..dec4ab846 100644 --- a/lib/wallets/crypto_currency/coins/peercoin.dart +++ b/lib/wallets/crypto_currency/coins/peercoin.dart @@ -254,4 +254,7 @@ class Peercoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 3; } diff --git a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart index 4dd224aed..30ddf7c70 100644 --- a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart +++ b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart @@ -1,5 +1,5 @@ import '../intermediate/bip39_hd_currency.dart'; mixin ElectrumXCurrencyInterface on Bip39HDCurrency { - // + int get transactionVersion; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index eda467a6a..f6ca3ab71 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -4,6 +4,7 @@ import 'dart:typed_data'; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:isar/isar.dart'; + import '../../../electrumx_rpc/cached_electrumx_client.dart'; import '../../../electrumx_rpc/client_manager.dart'; import '../../../electrumx_rpc/electrumx_client.dart'; @@ -651,7 +652,7 @@ mixin ElectrumXInterface final List prevOuts = []; coinlib.Transaction clTx = coinlib.Transaction( - version: 1, // TODO: check if we can use 3 (as is default in coinlib) + version: cryptoCurrency.transactionVersion, inputs: [], outputs: [], ); From 88f462f43ecc22fa8f62230244b77a4c629928ee Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 5 Jun 2024 17:19:33 -0500 Subject: [PATCH 2/4] add transactionVersion overrides for all coins ecash and particl may vary, need to verify. --- lib/wallets/crypto_currency/coins/bitcoin.dart | 4 ++++ lib/wallets/crypto_currency/coins/bitcoincash.dart | 3 +++ lib/wallets/crypto_currency/coins/dogecoin.dart | 4 ++++ lib/wallets/crypto_currency/coins/ecash.dart | 3 +++ lib/wallets/crypto_currency/coins/firo.dart | 6 +++++- lib/wallets/crypto_currency/coins/litecoin.dart | 4 ++++ lib/wallets/crypto_currency/coins/namecoin.dart | 3 +++ lib/wallets/crypto_currency/coins/particl.dart | 3 +++ 8 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/wallets/crypto_currency/coins/bitcoin.dart b/lib/wallets/crypto_currency/coins/bitcoin.dart index 118d61f24..ffdd4c15d 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin.dart @@ -1,4 +1,5 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; + import '../../../models/isar/models/blockchain_data/address.dart'; import '../../../models/node_model.dart'; import '../../../utilities/amount/amount.dart'; @@ -291,4 +292,7 @@ class Bitcoin extends Bip39HDCurrency ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index 25e18f6a3..8a2f91aae 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -364,4 +364,7 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/dogecoin.dart b/lib/wallets/crypto_currency/coins/dogecoin.dart index 3e1824e48..cbb9bea1e 100644 --- a/lib/wallets/crypto_currency/coins/dogecoin.dart +++ b/lib/wallets/crypto_currency/coins/dogecoin.dart @@ -1,4 +1,5 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; + import '../../../models/isar/models/blockchain_data/address.dart'; import '../../../models/node_model.dart'; import '../../../utilities/amount/amount.dart'; @@ -248,4 +249,7 @@ class Dogecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index f20b9a52c..a68a82dcd 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -338,4 +338,7 @@ class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/firo.dart b/lib/wallets/crypto_currency/coins/firo.dart index d9dbe3e65..6880190b6 100644 --- a/lib/wallets/crypto_currency/coins/firo.dart +++ b/lib/wallets/crypto_currency/coins/firo.dart @@ -1,13 +1,14 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; + import '../../../models/isar/models/blockchain_data/address.dart'; import '../../../models/node_model.dart'; import '../../../utilities/amount/amount.dart'; import '../../../utilities/default_nodes.dart'; import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../wallet/wallet_mixin_interfaces/spark_interface.dart'; import '../crypto_currency.dart'; import '../interfaces/electrumx_currency_interface.dart'; import '../intermediate/bip39_hd_currency.dart'; -import '../../wallet/wallet_mixin_interfaces/spark_interface.dart'; class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface { Firo(super.network) { @@ -266,4 +267,7 @@ class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/litecoin.dart b/lib/wallets/crypto_currency/coins/litecoin.dart index 89346e509..880a3260e 100644 --- a/lib/wallets/crypto_currency/coins/litecoin.dart +++ b/lib/wallets/crypto_currency/coins/litecoin.dart @@ -1,4 +1,5 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; + import '../../../models/isar/models/blockchain_data/address.dart'; import '../../../models/node_model.dart'; import '../../../utilities/amount/amount.dart'; @@ -279,4 +280,7 @@ class Litecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/namecoin.dart b/lib/wallets/crypto_currency/coins/namecoin.dart index daca04916..371406ddf 100644 --- a/lib/wallets/crypto_currency/coins/namecoin.dart +++ b/lib/wallets/crypto_currency/coins/namecoin.dart @@ -252,4 +252,7 @@ class Namecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } diff --git a/lib/wallets/crypto_currency/coins/particl.dart b/lib/wallets/crypto_currency/coins/particl.dart index 382602e7a..595f6fbf4 100644 --- a/lib/wallets/crypto_currency/coins/particl.dart +++ b/lib/wallets/crypto_currency/coins/particl.dart @@ -230,4 +230,7 @@ class Particl extends Bip39HDCurrency with ElectrumXCurrencyInterface { ); } } + + @override + int get transactionVersion => 1; } From 42ab07a5860c5d4e1eeb1c6f238a54862089ff84 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 5 Jun 2024 18:22:36 -0500 Subject: [PATCH 3/4] use tx ver # in paynym interface RIP --- .../wallet/wallet_mixin_interfaces/paynym_interface.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart index b9759d474..86cd8b66b 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart @@ -10,6 +10,8 @@ import 'package:bitcoindart/src/utils/script.dart' as bscript; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:isar/isar.dart'; import 'package:pointycastle/digests/sha256.dart'; +import 'package:tuple/tuple.dart'; + import '../../../exceptions/wallet/insufficient_balance_exception.dart'; import '../../../exceptions/wallet/paynym_send_exception.dart'; import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; @@ -29,7 +31,6 @@ import '../../crypto_currency/interfaces/paynym_currency_interface.dart'; import '../../models/tx_data.dart'; import '../intermediate/bip39_hd_wallet.dart'; import 'electrumx_interface.dart'; -import 'package:tuple/tuple.dart'; const String kPCodeKeyPrefix = "pCode_key_"; @@ -750,7 +751,7 @@ mixin PaynymInterface final List prevOuts = []; coinlib.Transaction clTx = coinlib.Transaction( - version: 1, + version: cryptoCurrency.transactionVersion, inputs: [], outputs: [], ); From 6f4b3a76ac98319a888193d4064f2527d16a6e62 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Wed, 5 Jun 2024 18:36:32 -0500 Subject: [PATCH 4/4] change bch and ecash tx ver #s to 2 and use it in the bcash interface --- lib/wallets/crypto_currency/coins/bitcoincash.dart | 2 +- lib/wallets/crypto_currency/coins/ecash.dart | 2 +- lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index 8a2f91aae..fb2f66a92 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -366,5 +366,5 @@ class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface { } @override - int get transactionVersion => 1; + int get transactionVersion => 2; } diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index a68a82dcd..28529c56a 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -340,5 +340,5 @@ class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface { } @override - int get transactionVersion => 1; + int get transactionVersion => 2; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart index 9559fa848..be0727bfc 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart @@ -30,6 +30,8 @@ mixin BCashInterface testnet: cryptoCurrency.network == CryptoCurrencyNetwork.test, ); + builder.setVersion(cryptoCurrency.transactionVersion); + // temp tx data to show in gui while waiting for real data from server final List tempInputs = []; final List tempOutputs = [];