mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-13 08:38:43 +03:00
change address doesn't keep generating gaps
This commit is contained in:
parent
ea3376f0ee
commit
b4cd9c6d0e
@ -335,6 +335,7 @@
|
||||
:: if no peta (payer/value), just prints address
|
||||
::
|
||||
%generate-address
|
||||
:: TODO: find a way to not print the below for a change address
|
||||
?~ peta.upd ~&(> "wallet-hook: %generate-address: {<address.upd>}" `state)
|
||||
=/ [payer=ship value=sats] u.peta.upd
|
||||
:_ state(ps.piym (~(put by ps.piym) payer [xpub.upd address.upd payer value]))
|
||||
|
@ -136,8 +136,8 @@
|
||||
:: - generate new change address
|
||||
:: - add that address+change value to the txbu
|
||||
:: - send txbu update
|
||||
:: - send address update
|
||||
:: - send a request for info on the address (watch it)
|
||||
:: - DON'T send an address update for the address, since it's change
|
||||
::
|
||||
:: TODO: end to end tests
|
||||
%generate-txbu
|
||||
@ -155,11 +155,10 @@
|
||||
?~ chng
|
||||
[~[(send-update [%generate-txbu xpub.act u.tb])] state]
|
||||
=/ [addr=address:btc =idx w=walt]
|
||||
~(gen-address wad u.uw %1)
|
||||
~(nixt-address wad u.uw %1)
|
||||
=+ new-txbu=(~(add-output txb u.tb) addr u.chng `[fprint.w bipt.w %1 idx])
|
||||
:_ state(walts (~(put by walts) xpub.act w))
|
||||
:~ (send-update [%generate-txbu xpub.act new-txbu])
|
||||
(send-update [%generate-address xpub.act addr ~])
|
||||
%+ send-request ~[requests-path]
|
||||
:* %address-info last-block
|
||||
addr xpub.act %1 idx
|
||||
|
@ -80,14 +80,31 @@
|
||||
?: ?=(%bip84 bipt.w)
|
||||
(need (encode-pubkey:bech32:btc %main dat:(pubkey idx)))
|
||||
~|("legacy addresses not supported yet " !!)
|
||||
:: generates and watches the next available address
|
||||
:: +nixt-address: used to get change addresses
|
||||
:: - gets the current next available address
|
||||
:: - doesn't bump nixt-address if it's unused
|
||||
:: - if used, fall back to gen-address and make a new one
|
||||
::
|
||||
++ nixt-address
|
||||
^- (trel address:btc idx:btc walt)
|
||||
=/ addr (mk-address nixt-idx)
|
||||
~| "lib/btc-wallet-store: get-next-address: nixt shouldn't be blank"
|
||||
=/ =addi (~(got by wach.w) addr)
|
||||
?. used.addi
|
||||
[addr nixt-idx w]
|
||||
gen-address
|
||||
::
|
||||
:: +gen-address:
|
||||
:: - generates the next available address
|
||||
:: - watches it (using update address)
|
||||
::
|
||||
++ gen-address
|
||||
^- (trel address:btc idx:btc walt)
|
||||
=/ addr (mk-address nixt-idx)
|
||||
:* addr
|
||||
nixt-idx
|
||||
(update-address addr [%.n chyg nixt-idx *(set utxo:btc)])
|
||||
%+ update-address addr
|
||||
[%.n chyg nixt-idx *(set utxo:btc)]
|
||||
==
|
||||
:: +update-address
|
||||
:: - insert a new address
|
||||
@ -112,7 +129,7 @@
|
||||
?:(?=(%0 chyg) p.nixt.w q.nixt.w)
|
||||
:: +bump-nixt: return wallet with bumped nixt
|
||||
:: - find next unused address
|
||||
:: - add that address to wach
|
||||
:: - watches that address
|
||||
:: - crashes if max-index is passed
|
||||
::
|
||||
++ bump-nixt
|
||||
|
Loading…
Reference in New Issue
Block a user