move tx creation after ins/outs and added another null check

This commit is contained in:
julian 2023-01-23 13:46:56 -06:00
parent 69dfbb5873
commit 5eb4b3bff5

View file

@ -152,24 +152,6 @@ mixin ElectrumXParsing {
type == TransactionType.incoming && type == TransactionType.incoming &&
transactionAddress.subType == AddressSubType.paynymNotification; transactionAddress.subType == AddressSubType.paynymNotification;
final tx = Transaction(
walletId: walletId,
txid: txData["txid"] as String,
timestamp: txData["blocktime"] as int? ??
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
type: type,
subType: isNotificationTx
? TransactionSubType.bip47Notification
: TransactionSubType.none,
amount: amount,
fee: fee,
height: txData["height"] as int?,
isCancelled: false,
isLelantus: false,
slateId: null,
otherData: null,
);
List<Output> outs = []; List<Output> outs = [];
List<Input> ins = []; List<Input> ins = [];
@ -196,7 +178,8 @@ mixin ElectrumXParsing {
scriptPubKeyType: json['scriptPubKey']?['type'] as String?, scriptPubKeyType: json['scriptPubKey']?['type'] as String?,
scriptPubKeyAddress: scriptPubKeyAddress:
json["scriptPubKey"]?["addresses"]?[0] as String? ?? json["scriptPubKey"]?["addresses"]?[0] as String? ??
json['scriptPubKey']['type'] as String, json['scriptPubKey']?['type'] as String? ??
"",
value: Format.decimalAmountToSatoshis( value: Format.decimalAmountToSatoshis(
Decimal.parse(json["value"].toString()), Decimal.parse(json["value"].toString()),
coin, coin,
@ -205,6 +188,24 @@ mixin ElectrumXParsing {
outs.add(output); outs.add(output);
} }
final tx = Transaction(
walletId: walletId,
txid: txData["txid"] as String,
timestamp: txData["blocktime"] as int? ??
(DateTime.now().millisecondsSinceEpoch ~/ 1000),
type: type,
subType: isNotificationTx
? TransactionSubType.bip47Notification
: TransactionSubType.none,
amount: amount,
fee: fee,
height: txData["height"] as int?,
isCancelled: false,
isLelantus: false,
slateId: null,
otherData: null,
);
return Tuple4(tx, outs, ins, transactionAddress); return Tuple4(tx, outs, ins, transactionAddress);
} }
} }