fix: silent payment txs not being restored

This commit is contained in:
Rafael Saes 2024-04-15 08:31:26 -03:00
parent 615db5a6d4
commit a887ea74b5

View file

@ -158,8 +158,10 @@ class ElectrumTransactionInfo extends TransactionInfo {
}
factory ElectrumTransactionInfo.fromJson(Map<String, dynamic> data, WalletType type) {
final inputAddresses = data['inputAddresses'] as List<dynamic>;
final outputAddresses = data['outputAddresses'] as List<dynamic>;
final inputAddresses = data['inputAddresses'] as List<dynamic>? ?? [];
final outputAddresses = data['outputAddresses'] as List<dynamic>? ?? [];
final unspents = data['unspents'] as List<dynamic>? ?? [];
return ElectrumTransactionInfo(
type,
id: data['id'] as String,
@ -175,13 +177,11 @@ class ElectrumTransactionInfo extends TransactionInfo {
outputAddresses:
outputAddresses.isEmpty ? [] : outputAddresses.map((e) => e.toString()).toList(),
to: data['to'] as String?,
unspents: data['unspents'] != null
? (data['unspents'] as List<dynamic>)
.map((unspent) => BitcoinUnspent.fromJSON(
BitcoinSilentPaymentAddressRecord.fromJSON(unspent['address_record'].toString()),
unspent as Map<String, dynamic>))
.toList()
: null,
unspents: unspents
.map((unspent) => BitcoinUnspent.fromJSON(
BitcoinSilentPaymentAddressRecord.fromJSON(unspent['address_record'].toString()),
unspent as Map<String, dynamic>))
.toList(),
);
}