btc: retry logic for unconfirmed balance, show it on frontend

This commit is contained in:
pkova 2021-04-26 17:46:44 +03:00 committed by ixv
parent 78a7dd256f
commit 1a096efbba
4 changed files with 37 additions and 13 deletions

View File

@ -89,8 +89,8 @@
|= old-state=vase
^- (quip card _this)
~& > '%btc-wallet recompiled'
:: `this(state !<(versioned-state old-state))
`this(state *state-0)
`this(state !<(versioned-state old-state))
:: `this(state *state-0)
++ on-poke
|= [=mark =vase]
^- (quip card _this)
@ -658,6 +658,7 @@
==
;: weld
:: (retry-addrs network)
retry-mempool-addresses
retry-ahistorical-txs
(retry-pend-piym network)
==
@ -667,6 +668,14 @@
%+ turn ~(tap in ahistorical-txs)
|= =txid
(poke-provider [%tx-info txid])
::
++ retry-mempool-addresses
^- (list card)
%+ turn
~(tap in ~(key by mempool-addresses))
|= =address
(poke-provider [%address-info address])
::
++ retry-scans
|= =network
@ -681,7 +690,6 @@
++ retry-addrs
|= =network
^- (list card)
~& %retry-addrs
%- zing
%+ murn ~(val by walts)
|= w=walt
@ -723,7 +731,6 @@
++ retry-pend-piym
|= =network
^- (list card)
~& %retry-pend-piym
%+ murn ~(tap by pend.piym)
|= [=txid p=payment]
=/ w (~(get by walts) xpub.p)
@ -769,7 +776,6 @@
++ handle-tx-info
|= ti=info:tx
^- (quip card _state)
~& %handle-tx-info^ti
|^
=/ h (~(get by history) txid.ti)
=. ahistorical-txs (~(del in ahistorical-txs) txid.ti)
@ -789,14 +795,12 @@
=. mempool-addresses
%+ roll inputs.ti
|= [=val:tx out=_mempool-addresses]
^- (set condition)
?: (is-our-address address.val)
(~(put ju out) address.val [%exclude txid.val])
out
=. mempool-addresses
%+ roll ouputs.ti
%+ roll outputs.ti
|= [=val:tx out=_mempool-addresses]
^- (set condition)
?: (is-our-address address.val)
(~(put ju out) address.val [%include txid.val])
out
@ -869,6 +873,20 @@
=/ ac (address-coords:bl address ~(val by walts))
?~ ac
`state
::
=/ cons=(set condition) (~(get ju mempool-addresses) address)
=/ new-cons=(set condition)
%- silt
%+ skip ~(tap in cons)
|= =condition
?: =(%include -.condition)
(~(any in utxos) |=(=utxo =(txid.utxo txid.condition)))
(~(all in utxos) |=(=utxo !=(txid.utxo txid.condition)))
=. mempool-addresses
?~ new-cons
(~(del by mempool-addresses) address)
(~(put by mempool-addresses) address new-cons)
::
=/ [w=walt =chyg =idx] u.ac
=. walts
%+ ~(put by walts) xpub.w

View File

@ -45,7 +45,11 @@ export default class Balance extends Component {
render() {
const sats = (this.props.state.balance || 0);
const sats = (this.props.state.confirmedBalance || 0);
const unconfirmedSats = this.props.state.unconfirmedBalance;
const unconfirmedString = unconfirmedSats ? ` (${unconfirmedSats}) ` : '';
const denomination = this.props.state.denomination;
const value = satsToCurrency(sats, denomination, this.props.state.currencyRates);
const sendDisabled = (sats === 0);
@ -92,7 +96,7 @@ export default class Balance extends Component {
</Row>
<Col justifyContent="center" alignItems="center">
<Text fontSize="52px" color="orange">{value}</Text>
<Text fontSize={1} color="orange">{sats} sats</Text>
<Text fontSize={1} color="orange">{`${sats}${unconfirmedString} sats`}</Text>
</Col>
<Row flexDirection="row-reverse">
<Button children="Send"

View File

@ -7,10 +7,11 @@ export class InitialReducer {
if (data) {
state.provider = data.provider;
state.wallet = data.wallet;
state.balance = _.get(data.balance, 'confirmed', null);
state.confirmedBalance = _.get(data.balance, 'confirmed', null);
state.unconfirmedBalance = _.get(data.balance, 'unconfirmed', null);
state.btcState = data['btc-state'];
state.history = this.reduceHistory(data.history);
state.address = data.address
state.address = data.address;
state.loaded = true;
}
}

View File

@ -10,7 +10,8 @@ class Store {
shipWallets: {},
provider: null,
wallet: null,
balance: null,
confirmedBalance: null,
unconfirmedBalance: null,
btcState: null,
history: [],
psbt: '',