Skip to content

Commit

Permalink
1.2.8 (#255)
Browse files Browse the repository at this point in the history
* chore: Update version number to 1.2.8 in pubspec.yaml

* feat: Add broadcast transaction functionality to WalletSignTransactionConfirmationScreen

* feat: Add tap functionality to 'Broadcast' button in key_new.dart
  • Loading branch information
willyfromtheblock authored May 27, 2024
1 parent a02fbd0 commit f9b29dc
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### **1.2.8** (2023-05-27)

- Allow broadcast of signed transactions if all inputs are signed

### **1.2.7** (2023-05-24)

- Various bug fixes and improvements related to flutter upgrade
Expand Down
6 changes: 5 additions & 1 deletion assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -514,5 +514,9 @@
"sign_transaction_inputs": "Inputs",
"sign_transaction_confirmation_title": "Please review transaction",
"sign_transaction_confirmation_input_signed": "Signed",
"sign_transaction_confirmation_input_unsigned": "Not signed"
"sign_transaction_confirmation_input_unsigned": "Not signed",
"sign_transaction_confirmation_broadcast": "Broadcast",
"sign_transaction_confirmation_broadcast_snack": "Transaction broadcast attempted",
"sign_transaction_confirmation_dialog_title": "Broadcast Transaction",
"sign_transaction_confirmation_dialog_content": "Please confirm that you want to broadcast this transaction."
}
4 changes: 4 additions & 0 deletions lib/screens/wallet/wallet_sign_transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ class _WalletSignTransactionScreenState
),
small: true,
),
if (_signingAddress.isNotEmpty && kIsWeb)
const SizedBox(
height: 20,
),
_signingAddress.isNotEmpty
? PeerButton(
action: () => _copyPubKeyToClipboard(
Expand Down
100 changes: 100 additions & 0 deletions lib/screens/wallet/wallet_sign_transaction_confirmation.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'dart:typed_data';
import 'package:coinlib_flutter/coinlib_flutter.dart';
import 'package:flutter/material.dart';
import 'package:peercoin/providers/connection_provider.dart';
import 'package:peercoin/screens/wallet/transaction_details.dart';
import 'package:peercoin/tools/generic_address.dart';
import 'package:peercoin/tools/app_localizations.dart';
import 'package:peercoin/widgets/buttons.dart';
import 'package:peercoin/widgets/double_tab_to_clipboard.dart';
import 'package:peercoin/widgets/service_container.dart';
import 'package:provider/provider.dart';

class WalletSignTransactionConfirmationArguments {
Transaction tx;
Expand Down Expand Up @@ -90,6 +93,84 @@ class WalletSignTransactionConfirmationScreen extends StatelessWidget {
return list;
}

Future<void> broadcastTransaction({
required String hex,
required String txId,
required BuildContext context,
}) async {
final connectionProvider = context.read<ConnectionProvider>();

showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
AppLocalizations.instance
.translate('sign_transaction_confirmation_dialog_title'),
textAlign: TextAlign.center,
),
content: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
AppLocalizations.instance
.translate('sign_transaction_confirmation_dialog_content'),
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 16,
letterSpacing: 1.2,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.error,
),
),
],
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: Text(
AppLocalizations.instance
.translate('server_settings_alert_cancel'),
),
),
TextButton(
onPressed: () async {
//broadcast transaction
connectionProvider.broadcastTransaction(
hex,
txId,
);

//show snack bar
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
AppLocalizations.instance.translate(
'sign_transaction_confirmation_broadcast_snack',
),
textAlign: TextAlign.center,
),
duration: const Duration(seconds: 3),
),
);

//close dialog
Navigator.pop(context);
},
child: Text(
AppLocalizations.instance
.translate('sign_transaction_confirmation_broadcast'),
),
),
],
);
},
);
}

@override
Widget build(BuildContext context) {
final WalletSignTransactionConfirmationArguments arguments =
Expand All @@ -113,6 +194,8 @@ class WalletSignTransactionConfirmationScreen extends StatelessWidget {
final decimalProduct = arguments.decimalProduct;
final selectedInputs = arguments.selectedInputs;
final coinLetterCode = arguments.coinLetterCode;
final txReadyForBroadcast =
(selectedInputs.length == tx.inputs.length) && tx.complete;

return Scaffold(
appBar: AppBar(
Expand Down Expand Up @@ -201,6 +284,23 @@ class WalletSignTransactionConfirmationScreen extends StatelessWidget {
clipBoardData: tx.toHex(),
child: SelectableText(tx.toHex()),
),
if (txReadyForBroadcast)
const SizedBox(
height: 20,
),
if (txReadyForBroadcast)
Center(
child: PeerButton(
text: AppLocalizations.instance.translate(
'sign_transaction_confirmation_broadcast',
),
action: () => broadcastTransaction(
hex: tx.toHex(),
txId: tx.txid,
context: context,
),
),
),
],
),
),
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.2.7+140
version: 1.2.8+141

environment:
sdk: '>=3.2.0 <4.0.0'
Expand Down
2 changes: 2 additions & 0 deletions test_driver/key_new.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ void main() {
'0300000001d8af09713b116ecce194add86bd6def0e2dc3abe99c53bfbcd34576061baca9f000000006a47304402200455cf81bde046213814387da5bde30e657fe7977c4c35ffe78edd3fe5cada7b0220186524598ac87de9b944f61e819b29c8a9a331c8a52b1694b8559cd9ec3395800121022ef8df0bfd68434e2db934e88a7e30b06b88507dac60fa7cc2b732a1b5147ef7ffffffff010a8f9800000000001976a914ff9296d92c5efc397d0e0b9ebe94d95a532270c488ac00000000',
),
);
await driver.tap(find.text('Broadcast'));
await driver.tap(find.text('Cancel'));
});

test('Transaction signing, fail', () async {
Expand Down

0 comments on commit f9b29dc

Please sign in to comment.