btc: record history for transactions that occur outside wallet flow

This commit is contained in:
Isaac Visintainer 2021-04-08 16:11:31 -07:00 committed by ixv
parent 2afa80a638
commit 6992a34040

View File

@ -35,6 +35,7 @@
feybs=(map ship sats) feybs=(map ship sats)
=piym =piym
=poym =poym
ahistorical-txs=(set txid)
== ==
:: ::
+$ card card:agent:gall +$ card card:agent:gall
@ -76,6 +77,7 @@
*(map ship sats) *(map ship sats)
*^piym *^piym
*^poym *^poym
~
== ==
== ==
++ on-save ++ on-save
@ -270,7 +272,6 @@
=+ n=(~(gut by num-fam.piym) f 0) =+ n=(~(gut by num-fam.piym) f 0)
?: (gte n fam-limit.params) ?: (gte n fam-limit.params)
~|("More than {<fam-limit.params>} addresses for moons + planet" !!) ~|("More than {<fam-limit.params>} addresses for moons + planet" !!)
=. state state(num-fam.piym (~(put by num-fam.piym) f +(n))) =. state state(num-fam.piym (~(put by num-fam.piym) f +(n)))
=^ a=address state =^ a=address state
(generate-address u.curr-xpub %0) (generate-address u.curr-xpub %0)
@ -573,13 +574,23 @@
== ==
?: ?|(?!(connected.p) (lth block.btc-state block)) ?: ?|(?!(connected.p) (lth block.btc-state block))
;: weld ;: weld
(retry-pend-piym network) (retry-pend-piym network)
(retry-poym network) (retry-poym network)
(retry-addrs network) (retry-addrs network)
(retry-txs network) (retry-txs network)
(retry-scans network) (retry-scans network)
retry-ahistorical-txs
== ==
(retry-pend-piym network) ;: weld
retry-ahistorical-txs
(retry-pend-piym network)
==
::
++ retry-ahistorical-txs
^- (list card)
%+ turn ~(tap in ahistorical-txs)
|= =txid
(poke-provider [%tx-info txid])
:: ::
++ retry-scans ++ retry-scans
|= =network |= =network
@ -677,6 +688,7 @@
^- _state ^- _state
|^ |^
=/ h (~(get by history) txid.ti) =/ h (~(get by history) txid.ti)
=. ahistorical-txs (~(del in ahistorical-txs) txid.ti)
=/ our-addrs=(set address) :: all our addresses in inputs/outputs of tx =/ our-addrs=(set address) :: all our addresses in inputs/outputs of tx
%- silt %- silt
%+ skim %+ skim
@ -743,22 +755,37 @@
|= [=address utxos=(set utxo) used=?] |= [=address utxos=(set utxo) used=?]
^- (quip card _state) ^- (quip card _state)
=/ ac (address-coords:bl address ~(val by walts)) =/ ac (address-coords:bl address ~(val by walts))
?~ ac `state ?~ ac
`state
=/ [w=walt =chyg =idx] u.ac =/ [w=walt =chyg =idx] u.ac
=. walts =. walts
%+ ~(put by walts) xpub.w %+ ~(put by walts) xpub.w
%+ ~(update-address wad:bl w chyg) %+ ~(update-address wad:bl w chyg)
address address
[used chyg idx utxos] [used chyg idx utxos]
:: if transactions haven't made it into history, request transaction info
::
=^ cards=(list card) ahistorical-txs
%+ roll ~(tap in utxos)
|= [u=utxo cad=(list card) ah=(set txid)]
^- [(list card) (set txid)]
?: (~(has by history) txid.u)
[cad ah]
:- [(poke-provider [%tx-info txid.u]) cad]
(~(put by ah) txid.u)
:: 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])
?~ b `state ?~ b
[cards state]
=. scans =. scans
(del-scanned u.b(has-used ?|(used has-used.u.b)) xpub.w chyg idx) (del-scanned u.b(has-used ?|(used has-used.u.b)) xpub.w chyg idx)
?: empty:(scan-status xpub.w chyg) ?: empty:(scan-status xpub.w chyg)
(check-scan xpub.w) =^ scan-cards=(list card) state
`state (check-scan xpub.w)
[(weld scan-cards cards) state]
::
[cards state]
:: +req-scan :: +req-scan
:: - adds addresses in batch to wallet's watch map as un-used addresses :: - adds addresses in batch to wallet's watch map as un-used addresses
:: - returns provider %address-info request cards :: - returns provider %address-info request cards
@ -778,7 +805,7 @@
scans scans
(~(put by scans) [xpub chyg] b) (~(put by scans) [xpub chyg] b)
walts walts
(~(put by walts) xpub w) (~(put by walts) xpub w)
== ==
:: ::
++ scan-status ++ scan-status