CW-289-Fix bitcoin pending send receive transactions not showing until confirmed (#878)

* Fix error in rendering pending transactions in different device

* Show pending status

* Fix broken subscription stream
This commit is contained in:
Godwin Asuquo 2023-04-20 23:20:37 +03:00 committed by GitHub
parent ab20312e61
commit 3fc927f742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View file

@ -410,7 +410,7 @@ class ElectrumClient {
switch (method) { switch (method) {
case 'blockchain.scripthash.subscribe': case 'blockchain.scripthash.subscribe':
final params = request['params'] as List<dynamic>; final params = request['params'] as List<dynamic>;
final scripthash = params.first as String; final scripthash = params.first as String?;
final id = 'blockchain.scripthash.subscribe:$scripthash'; final id = 'blockchain.scripthash.subscribe:$scripthash';
_tasks[id]?.subject?.add(params.last); _tasks[id]?.subject?.add(params.last);
@ -430,15 +430,17 @@ class ElectrumClient {
void _handleResponse(Map<String, dynamic> response) { void _handleResponse(Map<String, dynamic> response) {
final method = response['method']; final method = response['method'];
final id = response['id'] as String; final id = response['id'] as String?;
final result = response['result']; final result = response['result'];
if (method is String) { if (method is String) {
_methodHandler(method: method, request: response); _methodHandler(method: method, request: response);
return; return;
} }
_finish(id, result); if (id != null){
_finish(id, result);
}
} }
} }

View file

@ -136,7 +136,7 @@ class ElectrumTransactionInfo extends TransactionInfo {
return ElectrumTransactionInfo(type, return ElectrumTransactionInfo(type,
id: bundle.originalTransaction.getId(), id: bundle.originalTransaction.getId(),
height: height, height: height,
isPending: false, isPending: bundle.confirmations == 0,
fee: fee, fee: fee,
direction: direction, direction: direction,
amount: amount, amount: amount,

View file

@ -537,8 +537,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
final transactionHex = verboseTransaction['hex'] as String; final transactionHex = verboseTransaction['hex'] as String;
final original = bitcoin.Transaction.fromHex(transactionHex); final original = bitcoin.Transaction.fromHex(transactionHex);
final ins = <bitcoin.Transaction>[]; final ins = <bitcoin.Transaction>[];
final time = verboseTransaction['time'] as int; final time = verboseTransaction['time'] as int?;
final confirmations = verboseTransaction['confirmations'] as int ?? 0; final confirmations = verboseTransaction['confirmations'] as int? ?? 0;
for (final vin in original.ins) { for (final vin in original.ins) {
final id = HEX.encode(vin.hash!.reversed.toList()); final id = HEX.encode(vin.hash!.reversed.toList());