mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-27 04:35:53 +00:00
replace bitcoindart with coinlib
This commit is contained in:
parent
af40bf3667
commit
55e6e56a2d
4 changed files with 38 additions and 16 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 75aa93ba25e59f19c90825ac2e9114b20ac3e538
|
Subproject commit 2ad67494611097d2471ff1f3a1f57c88e8f38ce8
|
|
@ -2,6 +2,7 @@ import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:convert/convert.dart';
|
||||||
import 'package:decimal/decimal.dart';
|
import 'package:decimal/decimal.dart';
|
||||||
import 'package:fusiondart/fusiondart.dart';
|
import 'package:fusiondart/fusiondart.dart';
|
||||||
import 'package:fusiondart/src/models/address.dart' as fusion_address;
|
import 'package:fusiondart/src/models/address.dart' as fusion_address;
|
||||||
|
@ -527,10 +528,7 @@ extension FusionTransaction on Transaction {
|
||||||
fusionTransaction.Inputs = await Future.wait(inputs.map((input) async {
|
fusionTransaction.Inputs = await Future.wait(inputs.map((input) async {
|
||||||
// Find input amount.
|
// Find input amount.
|
||||||
Map<String, dynamic> _tx = await cachedElectrumX.getTransaction(
|
Map<String, dynamic> _tx = await cachedElectrumX.getTransaction(
|
||||||
coin: Coin.bitcoincash,
|
coin: Coin.bitcoincash, txHash: input.txid, verbose: true);
|
||||||
txHash: input.txid,
|
|
||||||
verbose: true,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (_tx.isEmpty) {
|
if (_tx.isEmpty) {
|
||||||
throw Exception("Transaction not found for input: ${input.txid}");
|
throw Exception("Transaction not found for input: ${input.txid}");
|
||||||
|
@ -545,14 +543,20 @@ extension FusionTransaction on Transaction {
|
||||||
"Output value at index ${input.vout} in transaction ${input.txid} not found",
|
"Output value at index ${input.vout} in transaction ${input.txid} not found",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (_tx["vout"] == null) {
|
||||||
final scriptPubKeyHex =
|
throw Exception("Vout in transaction ${input.txid} is null");
|
||||||
_tx["vout"]?[input.vout]?["scriptPubKey"] as String?;
|
|
||||||
if (scriptPubKeyHex == null) {
|
|
||||||
throw Exception(
|
|
||||||
"scriptPubKey of vout index ${input.vout} in transaction is null",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
if (_tx["vout"][input.vout] == null) {
|
||||||
|
throw Exception("Vout index ${input.vout} in transaction is null");
|
||||||
|
}
|
||||||
|
if (_tx["vout"][input.vout]["scriptPubKey"] == null) {
|
||||||
|
throw Exception("scriptPubKey at vout index ${input.vout} is null");
|
||||||
|
}
|
||||||
|
if (_tx["vout"][input.vout]["scriptPubKey"]["hex"] == null) {
|
||||||
|
throw Exception(
|
||||||
|
"scriptPubKey hex of vout index ${input.vout} in transaction is null");
|
||||||
|
}
|
||||||
|
// TODO replace with conditional chaining?
|
||||||
|
|
||||||
// Assign vout value to amount.
|
// Assign vout value to amount.
|
||||||
final value = Amount.fromDecimal(
|
final value = Amount.fromDecimal(
|
||||||
|
@ -563,7 +567,7 @@ extension FusionTransaction on Transaction {
|
||||||
return fusion_input.Input(
|
return fusion_input.Input(
|
||||||
prevTxid: utf8.encode(input.txid),
|
prevTxid: utf8.encode(input.txid),
|
||||||
prevIndex: input.vout,
|
prevIndex: input.vout,
|
||||||
pubKey: scriptPubKeyHex.toUint8ListFromHex,
|
pubKey: hex.decode("${_tx["vout"][input.vout]["scriptPubKey"]["hex"]}"),
|
||||||
amount: value.raw.toInt(),
|
amount: value.raw.toInt(),
|
||||||
);
|
);
|
||||||
}).toList());
|
}).toList());
|
||||||
|
@ -585,7 +589,7 @@ extension FusionTransaction on Transaction {
|
||||||
address: outputAddress,
|
address: outputAddress,
|
||||||
dbInstance: dbInstance,
|
dbInstance: dbInstance,
|
||||||
);
|
);
|
||||||
fusion_address.DerivationPath derivationPath;
|
fusion_address.DerivationPath? derivationPath;
|
||||||
if (derivationPathString == null) {
|
if (derivationPathString == null) {
|
||||||
// TODO: check on this:
|
// TODO: check on this:
|
||||||
// Either the address is not an address of this wallet
|
// Either the address is not an address of this wallet
|
||||||
|
@ -593,7 +597,7 @@ extension FusionTransaction on Transaction {
|
||||||
// If the former, then the issue cannot be easily solved as we will
|
// If the former, then the issue cannot be easily solved as we will
|
||||||
// have no way of finding out what the derivation path is.
|
// have no way of finding out what the derivation path is.
|
||||||
// Throw exception for now.
|
// Throw exception for now.
|
||||||
throw Exception("derivationPathString is null");
|
// throw Exception("derivationPathString is null");
|
||||||
} else {
|
} else {
|
||||||
derivationPath = fusion_address.DerivationPath(
|
derivationPath = fusion_address.DerivationPath(
|
||||||
derivationPathString,
|
derivationPathString,
|
||||||
|
|
18
pubspec.lock
18
pubspec.lock
|
@ -262,6 +262,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.6.0"
|
version: "4.6.0"
|
||||||
|
coinlib:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: coinlib
|
||||||
|
sha256: "410993f49aef30e48b76bbad8a33fef33f6b90e103b15b6be0277683ffe15399"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -287,7 +295,7 @@ packages:
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.4"
|
version: "1.2.4"
|
||||||
convert:
|
convert:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: convert
|
name: convert
|
||||||
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||||
|
@ -1861,6 +1869,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.0.12+1"
|
version: "0.0.12+1"
|
||||||
|
wasm_interop:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wasm_interop
|
||||||
|
sha256: b1b378f07a4cf0103c25faf34d9a64d2c3312135b9efb47e0ec116ec3b14e48f
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.1"
|
||||||
watcher:
|
watcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -149,6 +149,8 @@ dependencies:
|
||||||
bip340: ^0.2.0
|
bip340: ^0.2.0
|
||||||
tezart: ^2.0.5
|
tezart: ^2.0.5
|
||||||
socks5_proxy: ^1.0.3+dev.3
|
socks5_proxy: ^1.0.3+dev.3
|
||||||
|
coinlib: ^1.0.0
|
||||||
|
convert: ^3.1.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Loading…
Reference in a new issue