Skip to content

Commit

Permalink
1.10.0 1 (#206)
Browse files Browse the repository at this point in the history
* fix for new transaction format

* send tab: switch into new address, when adding one

* pre 0.12 backwards compatability
  • Loading branch information
willyfromtheblock authored Dec 5, 2022
1 parent da7916e commit 1a5ad87
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 39 deletions.
71 changes: 37 additions & 34 deletions lib/providers/active_wallets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -355,40 +355,43 @@ class ActiveWallets with ChangeNotifier {
for (var vOut in voutList) {
final asMap = vOut as Map;
if (asMap['scriptPubKey']['type'] != 'nulldata') {
asMap['scriptPubKey']['addresses'].forEach(
(addr) {
if (openWallet.addresses.firstWhereOrNull(
(element) => element.address == addr) !=
null) {
//address is ours, add new tx
final int txValue = (vOut['value'] * decimalProduct).toInt();

//increase notification value for addr
final addrInWallet = openWallet.addresses
.firstWhere((element) => element.address == addr);
addrInWallet.newNotificationBackendCount =
addrInWallet.notificationBackendCount + 1;
openWallet.save();

//write tx
openWallet.putTransaction(
WalletTransaction(
txid: tx['txid'],
timestamp: tx['blocktime'] ?? 0,
value: txValue,
fee: 0,
address: addr,
recipients: {addr: txValue},
direction: direction,
broadCasted: true,
confirmations: tx['confirmations'] ?? 0,
broadcastHex: '',
opReturn: '',
),
);
}
},
);
//pre 0.12 backwards compatability TODO remove after 0.12 HF
String addr;
if (asMap['scriptPubKey']['addresses'].runtimeType == List) {
addr = asMap['scriptPubKey']['addresses'][0];
}
addr = asMap['scriptPubKey']['address'];

if (openWallet.addresses
.firstWhereOrNull((element) => element.address == addr) !=
null) {
//address is ours, add new tx
final int txValue = (vOut['value'] * decimalProduct).toInt();

//increase notification value for addr
final addrInWallet = openWallet.addresses
.firstWhere((element) => element.address == addr);
addrInWallet.newNotificationBackendCount =
addrInWallet.notificationBackendCount + 1;
openWallet.save();

//write tx
openWallet.putTransaction(
WalletTransaction(
txid: tx['txid'],
timestamp: tx['blocktime'] ?? 0,
value: txValue,
fee: 0,
address: addr,
recipients: {addr: txValue},
direction: direction,
broadCasted: true,
confirmations: tx['confirmations'] ?? 0,
broadcastHex: '',
opReturn: '',
),
);
}
}
}

Expand Down
10 changes: 6 additions & 4 deletions lib/widgets/wallet/send_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,6 @@ class _SendTabState extends State<SendTab> {
bool fromImport = false,
}) {
if (triggerFormValidation() || fromImport == true) {
if (fromImport == false) {
_formKey.currentState!.save();
}
_labelControllerList.add(TextEditingController(text: label));
_addressControllerList.add(TextEditingController(text: address));
_amountControllerList.add(TextEditingController(text: amount.toString()));
Expand All @@ -535,7 +532,12 @@ class _SendTabState extends State<SendTab> {
_amountKeyList.add(GlobalKey<FormFieldState>());
_amountInputHelperTextList[_numberOfRecipients] = '';
_requestedAmountInCoinsList[_numberOfRecipients] = amount;

if (fromImport == false) {
_formKey.currentState!.save();
setState(() {
_currentAddressIndex = _numberOfRecipients;
});
}
return true;
}
return false;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: peercoin
description: A new Peercoin wallet.

version: 1.1.0+119
version: 1.1.0+120

environment:
sdk: '>=2.12.0 <3.0.0'
Expand Down

0 comments on commit 1a5ad87

Please sign in to comment.