mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
refactor bump-nixt
This commit is contained in:
parent
727e6b97b6
commit
1f229801c9
@ -335,7 +335,7 @@
|
|||||||
:: if no peta (payer/value), just prints address
|
:: if no peta (payer/value), just prints address
|
||||||
::
|
::
|
||||||
%generate-address
|
%generate-address
|
||||||
?~ peta.upd ~&(> address.upd `state)
|
?~ peta.upd ~&(> "wallet-hook: %generate-address: {<address.upd>}" `state)
|
||||||
=/ [payer=ship value=sats] u.peta.upd
|
=/ [payer=ship value=sats] u.peta.upd
|
||||||
:_ state(ps.piym (~(put by ps.piym) payer [xpub.upd address.upd payer value]))
|
:_ state(ps.piym (~(put by ps.piym) payer [xpub.upd address.upd payer value]))
|
||||||
~[(poke-wallet-hook payer [%ret-pay-address address.upd payer value])]
|
~[(poke-wallet-hook payer [%ret-pay-address address.upd payer value])]
|
||||||
|
@ -89,15 +89,18 @@
|
|||||||
nixt-idx
|
nixt-idx
|
||||||
(update-address addr [%.n chyg nixt-idx *(set utxo:btc)])
|
(update-address addr [%.n chyg nixt-idx *(set utxo:btc)])
|
||||||
==
|
==
|
||||||
:: insert a new address; update "nixt" free address if this one was it
|
:: +update-address
|
||||||
|
:: - insert a new address
|
||||||
|
:: - update "nixt" free address if this one was it
|
||||||
|
:: - watch the new nixt
|
||||||
::
|
::
|
||||||
++ update-address
|
++ update-address
|
||||||
|= [a=address:btc =addi]
|
|= [a=address:btc =addi]
|
||||||
^- walt
|
^- walt
|
||||||
?> =(chyg chyg.addi)
|
?> =(chyg chyg.addi)
|
||||||
?> =(a (mk-address idx.addi))
|
?> =(a (mk-address idx.addi))
|
||||||
=? nixt.w (is-nixt addi)
|
=? w (is-nixt addi)
|
||||||
new:bump-nixt
|
bump-nixt
|
||||||
w(wach (~(put by wach.w) a addi))
|
w(wach (~(put by wach.w) a addi))
|
||||||
::
|
::
|
||||||
++ is-nixt
|
++ is-nixt
|
||||||
@ -107,20 +110,24 @@
|
|||||||
=(idx.addi q.nixt.w)
|
=(idx.addi q.nixt.w)
|
||||||
++ nixt-idx
|
++ nixt-idx
|
||||||
?:(?=(%0 chyg) p.nixt.w q.nixt.w)
|
?:(?=(%0 chyg) p.nixt.w q.nixt.w)
|
||||||
:: Returns: the prior idx in the account
|
:: +bump-nixt: return wallet with bumped nixt
|
||||||
:: nixt with account idx bumped
|
:: - find next unused address
|
||||||
:: Increments idx until an unwatched address is found
|
:: - add that address to wach
|
||||||
:: Crashes if max-index is passed
|
:: - crashes if max-index is passed
|
||||||
::
|
::
|
||||||
++ bump-nixt
|
++ bump-nixt
|
||||||
|^ ^- [old=idx:btc new=nixt]
|
|^ ^- walt
|
||||||
:- nixt-idx
|
|
||||||
=/ new-idx=idx:btc +(nixt-idx)
|
=/ new-idx=idx:btc +(nixt-idx)
|
||||||
|- ?> (lte new-idx max-index)
|
|- ?> (lte new-idx max-index)
|
||||||
=/ a=(unit addi)
|
=+ addr=(mk-address new-idx)
|
||||||
(~(get by wach.w) (mk-address new-idx))
|
=/ =addi
|
||||||
?~ a (set-nixt new-idx)
|
%+ ~(gut by wach.w) addr
|
||||||
?: ?!(used.u.a) (set-nixt new-idx)
|
[%.n chyg new-idx *(set utxo:btc)]
|
||||||
|
?. used.addi
|
||||||
|
%= w
|
||||||
|
nixt (set-nixt new-idx)
|
||||||
|
wach (~(put by wach.w) addr addi)
|
||||||
|
==
|
||||||
$(new-idx +(new-idx))
|
$(new-idx +(new-idx))
|
||||||
::
|
::
|
||||||
++ set-nixt
|
++ set-nixt
|
||||||
|
Loading…
Reference in New Issue
Block a user