CAKE-333 | fixed commit() method in the pending_bitcoin_transaction.dart; added bitcoin_commit_transaction_exception.dart to the app

This commit is contained in:
OleksandrSobol 2021-06-24 18:59:19 +03:00
parent a423f4b776
commit 7724d5e248
2 changed files with 12 additions and 1 deletions

View file

@ -0,0 +1,4 @@
class BitcoinCommitTransactionException implements Exception {
@override
String toString() => 'Transaction commit is failed.';
}

View file

@ -1,3 +1,4 @@
import 'package:cake_wallet/bitcoin/bitcoin_commit_transaction_exception.dart';
import 'package:flutter/foundation.dart';
import 'package:bitcoin_flutter/bitcoin_flutter.dart' as bitcoin;
import 'package:cake_wallet/core/pending_transaction.dart';
@ -33,7 +34,13 @@ class PendingBitcoinTransaction with PendingTransaction {
@override
Future<void> commit() async {
await electrumClient.broadcastTransaction(transactionRaw: _tx.toHex());
final result =
await electrumClient.broadcastTransaction(transactionRaw: _tx.toHex());
if (result.isEmpty) {
throw BitcoinCommitTransactionException();
}
_listeners?.forEach((listener) => listener(transactionInfo()));
}