@@ -889,10 +889,10 @@ class PartiallySignedTransaction {
889
889
}
890
890
891
891
/// Return feeAmount
892
- Future <BigInt ?> feeAmount () async {
892
+ Future <int ?> feeAmount () async {
893
893
try {
894
894
final res = await Api .psbtFeeAmount (psbtStr: psbtBase64);
895
- return res;
895
+ return res? . toInt () ;
896
896
} on AnyhowException catch (e, s) {
897
897
Error .throwWithStackTrace (configException (e.message), s);
898
898
}
@@ -1140,8 +1140,8 @@ class TxBuilder {
1140
1140
}
1141
1141
1142
1142
///Add a recipient to the internal list
1143
- TxBuilder addRecipient (bridge.Script script, BigInt amount) {
1144
- _recipients.add (ScriptAmount (script: script, amount: amount));
1143
+ TxBuilder addRecipient (bridge.Script script, int amount) {
1144
+ _recipients.add (ScriptAmount (script: script, amount: BigInt . from ( amount) ));
1145
1145
return this ;
1146
1146
}
1147
1147
@@ -1189,7 +1189,7 @@ class TxBuilder {
1189
1189
ForeignUtxo (
1190
1190
outpoint: OutPoint (txid: ext.txid, vout: ext.vout),
1191
1191
txout: TxOutForeign (
1192
- value: ext.value,
1192
+ value: BigInt . from ( ext.value) ,
1193
1193
scriptPubkey: ext.scriptPk,
1194
1194
),
1195
1195
),
@@ -1325,12 +1325,12 @@ class TxBuilder {
1325
1325
return this ;
1326
1326
}
1327
1327
1328
- Future <BigInt ?> calNetworkFee (Wallet wallet) async {
1328
+ Future <int ?> calNetworkFee (Wallet wallet) async {
1329
1329
final res = await finish (wallet);
1330
1330
return res.psbt.feeAmount ();
1331
1331
}
1332
1332
1333
- Future <BigInt > calFee (Wallet wallet) async {
1333
+ Future <int > calFee (Wallet wallet) async {
1334
1334
final res = await Api .txCalFeeFinish (
1335
1335
wallet: wallet._wallet,
1336
1336
recipients: _recipients,
@@ -1347,26 +1347,26 @@ class TxBuilder {
1347
1347
changePolicy: _changeSpendPolicy,
1348
1348
shuffleUtxo: _shuffleUtxos,
1349
1349
);
1350
- return res;
1350
+ return res. toInt () ;
1351
1351
}
1352
1352
1353
- BigInt getTotalOutput () {
1354
- BigInt total = BigInt .zero ;
1353
+ int getTotalOutput () {
1354
+ int total = 0 ;
1355
1355
for (final e in _txOutputs) {
1356
1356
total += e.value;
1357
1357
}
1358
1358
return total;
1359
1359
}
1360
1360
1361
- BigInt getTotalInput () {
1362
- BigInt total = BigInt .zero ;
1361
+ int getTotalInput () {
1362
+ int total = 0 ;
1363
1363
for (final e in _txInputs) {
1364
1364
total += e.value;
1365
1365
}
1366
1366
return total;
1367
1367
}
1368
1368
1369
- BigInt getUnspend () {
1369
+ int getUnspend () {
1370
1370
return getTotalInput () - getTotalOutput ();
1371
1371
}
1372
1372
@@ -1425,7 +1425,7 @@ class InscriptionValue {
1425
1425
});
1426
1426
1427
1427
final String inscriptionId;
1428
- final BigInt outputValue;
1428
+ final int outputValue;
1429
1429
}
1430
1430
1431
1431
class OutPointExt extends OutPoint {
@@ -1441,7 +1441,7 @@ class OutPointExt extends OutPoint {
1441
1441
required this .scriptPk,
1442
1442
}) : super (txid: '' , vout: 0 );
1443
1443
1444
- final BigInt value;
1444
+ final int value;
1445
1445
final String scriptPk;
1446
1446
1447
1447
String get uniqueKey => '$txid :$vout ' ;
@@ -1517,26 +1517,26 @@ class TxBuilderResult {
1517
1517
1518
1518
bool ? signed;
1519
1519
1520
- BigInt getTotalInput () {
1521
- return _txInputs.fold (BigInt .zero , (p, v) => p + v.value);
1520
+ int getTotalInput () {
1521
+ return _txInputs.fold (0 , (p, v) => p + v.value);
1522
1522
}
1523
1523
1524
- BigInt getTotalOutput () {
1525
- return _txOutputs.fold (BigInt .zero , (p, v) => p + v.value);
1524
+ int getTotalOutput () {
1525
+ return _txOutputs.fold (0 , (p, v) => p + v.value);
1526
1526
}
1527
1527
1528
1528
Future <void > dumpTx ({
1529
1529
void Function (Object ? )? logPrint = print,
1530
1530
}) async {
1531
1531
final tx = await psbt.extractTx ();
1532
1532
final size = Uint8List .fromList (await tx.serialize ()).length;
1533
- final feePaid = await psbt.feeAmount ();
1533
+ final feePaid = BigInt . from (( await psbt.feeAmount ()) ! );
1534
1534
final feeRate = (await psbt.feeRate ())! .asSatPerVb ();
1535
1535
final inputs = await tx.input ();
1536
1536
final outputs = await tx.output ();
1537
1537
1538
1538
final inputStrings = < String > [];
1539
- BigInt totalInput = BigInt .zero ;
1539
+ int totalInput = 0 ;
1540
1540
for (int i = 0 ; i < _txInputs.length; i += 1 ) {
1541
1541
final input = _txInputs[i];
1542
1542
final found = inputs.firstWhereOrNull ((e) {
@@ -1583,7 +1583,7 @@ ${outputString.join("\n")}
1583
1583
Summary in Sats
1584
1584
Inputs: + $totalInput
1585
1585
Outputs: - $totalOutput
1586
- fee: - ${ feePaid !}
1586
+ fee: - $feePaid
1587
1587
Remain: ${totalOutput - feePaid }
1588
1588
==============================================================================================
1589
1589
''' );
@@ -1937,7 +1937,7 @@ class Wallet {
1937
1937
txId: txId,
1938
1938
index: i,
1939
1939
address: addr,
1940
- value: element.value,
1940
+ value: element.value. toInt () ,
1941
1941
isMine: addr.address == address,
1942
1942
isChange: false ,
1943
1943
),
@@ -1954,7 +1954,7 @@ class Wallet {
1954
1954
TxOutExt (
1955
1955
index: i,
1956
1956
address: addr,
1957
- value: element.value,
1957
+ value: element.value. toInt () ,
1958
1958
isMine: addr.address == address,
1959
1959
isChange: i == outputs.length - 1 ? true : false ,
1960
1960
),
@@ -1973,8 +1973,8 @@ class Wallet {
1973
1973
fee: feePaid! ,
1974
1974
feeRate: feeRate,
1975
1975
size: size,
1976
- totalInputValue: inputsExt.fold (BigInt .zero , (v, i) => i.value + v),
1977
- totalOutputValue: outputsExt.fold (BigInt .zero , (v, i) => i.value + v),
1976
+ totalInputValue: inputsExt.fold (0 , (v, i) => i.value + v),
1977
+ totalOutputValue: outputsExt.fold (0 , (v, i) => i.value + v),
1978
1978
psbt: psbt,
1979
1979
);
1980
1980
}
0 commit comments