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

View File

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

View File

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

View File

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