WIP: generate address
(handle-provider-update:hc !<(update:bp q.cage.sign))
::
%btc-wallet-store-request
- (handle-request:hc !<(request:bws q.cage.sign))
+ (handle-wallet-store-request:hc !<(request:bws q.cage.sign))
+ ::
+ %btc-wallet-store-update
+ (handle-wallet-store-update:hc !<(update:bws q.cage.sign))
==
[cards this]
==
`state(def-wallet `(snag 0 xs))
::
%req-pay-address
- :: TODO: gen-address in wallet-store
- :: handle response in on-agent-> wallet-store update
- :: TODO: check whether default-wallet has a value
- ?~ def-wallet ~& >>> "no default wallet" `state
- :- ~[(poke-wallet-store [%generate-address u.def-wallet %0])]
- state
+ ?< =(src.bowl payee.act) :: can't pay yourself
+ :_ state
+ ?. =(payee.act our.bowl) :: forward poke to payee
+ ~[(poke-wallet-hook payee.act act)]
+ ?~ def-wallet ~|("btc-wallet-hook: no def-wallet set" !!)
+ :~ %+ poke-wallet-store /[(scot %p src.bowl)]
+ [%generate-address u.def-wallet %0]
+ ==
::
%pay-address
`state
=/ ureq (~(get by padr) req-id.p.update)
?~ ureq `state
:_ state(padr (~(del by padr) req-id.p.update))
- :~ %- poke-wallet-store
+ :~ %+ poke-wallet-store /
:* %address-info xpub.u.ureq chyg.u.ureq idx.u.ureq
utxos.body.p.update used.body.p.update blockcount.body.p.update
==
==
==
::
-++ handle-request
+++ handle-wallet-store-request
|= req=request:bws
^- (quip card _state)
?- -.req
~
==
::
+++ handle-wallet-store-update
+ |= upd=update:bws
+ ^- (quip card _state)
+ ?- -.upd
+ %generate-address
+ :: TODO: add to piym
+ :: TODO: send to requesting wallet-hook
+ `state
+ ::
+ %scan-done
+ `state
+ ==
+::
++ retry
|= p=pend-addr
^- (list card)
?~ provider %.n
connected.u.provider
::
-++ poke-wallet-store
- |= act=action:bws ^- card
+++ poke-wallet-hook
+ |= [target=ship act=action]
+ ^- card
:* %pass /[(scot %da now.bowl)] %agent
- [our.bowl %btc-wallet-store] %poke
+ [target %btc-wallet-hook] %poke
+ %btc-wallet-hook-action !>(act)
+ ==
+::
+++ poke-wallet-store
+ |= [prefix=wire act=action:bws]
+ ^- card
+ :* %pass (weld prefix /[(scot %da now.bowl)])
+ %agent [our.bowl %btc-wallet-store] %poke
%btc-wallet-store-action !>(act)
==
::
