btc: add balance events on handle-address-info

This commit is contained in:
pkova 2021-04-27 19:53:50 +03:00 committed by ixv
parent 84ccb732e6
commit 4a0caa9fc3
4 changed files with 12 additions and 1 deletions

View File

@ -957,6 +957,7 @@
[cad ah]
:- [(poke-provider [%tx-info txid.u]) cad]
(~(put by ah) txid.u)
=. cards (snoc cards (give-update %balance current-balance))
:: if the wallet+chyg is being scanned, update the scan batch
::
=/ b (~(get by scans) [xpub.w chyg])

View File

@ -107,6 +107,7 @@
%new-tx (hest hest.upd)
%cancel-tx (hexb txid.upd)
%new-address (address address.upd)
%balance (balance balance.upd)
==
::
++ initial

View File

@ -118,7 +118,7 @@
$% $: %initial
provider=(unit provider)
wallet=(unit xpub)
balance=(unit [p=sats q=sats])
balance=(unit [confirmed=sats unconfirmed=sats])
=history
=btc-state
address=(unit address)
@ -130,6 +130,7 @@
[%new-tx =hest]
[%cancel-tx =txid]
[%new-address =address]
[%balance balance=(unit [confirmed=sats unconfirmed=sats])]
==
::
+$ condition

View File

@ -33,6 +33,9 @@ export class UpdateReducer {
if (json.address) {
this.reduceAddress(json.address, state);
}
if (json.balance) {
this.reduceBalance(json.balance, state);
}
}
reduceProviderStatus(json, state) {
@ -91,4 +94,9 @@ export class UpdateReducer {
reduceAddress(json, state) {
state.address = json;
}
reduceBalance(json, state) {
state.unconfirmedBalance = json.unconfirmed;
state.confirmedBalance = json.confirmed;
}
}