diff --git a/BTC.scratch.md b/BTC.scratch.md index 29320d298d..5d14579c8b 100644 --- a/BTC.scratch.md +++ b/BTC.scratch.md @@ -258,6 +258,8 @@ https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#P2SHP2WPKH %czar > (clan:title ~fipdul-podfer-bacdul-timzod) %earl +(clan:title ~lapfep-tipdys-difsum-natmug--novpub-matwes-sicrel-marzod) +%pawn :: sponsorship > (sein:title our now ~timluc-miptev) diff --git a/app/btc-wallet-hook.hoon b/app/btc-wallet-hook.hoon index f314a94c3c..1e3ee2acf6 100644 --- a/app/btc-wallet-hook.hoon +++ b/app/btc-wallet-hook.hoon @@ -27,6 +27,10 @@ def-wallet=(unit xpub) padr=pend-addr ptxb=pend-txbu + =piym + =poym + =piym-watch + =poym-watch == :: +$ card card:agent:gall @@ -94,7 +98,7 @@ (handle-wallet-store-request:hc !<(request:bws q.cage.sign)) :: %btc-wallet-store-update - (handle-wallet-store-update:hc !<(update:bws q.cage.sign)) + (handle-wallet-store-update:hc wire !<(update:bws q.cage.sign)) == [cards this] == @@ -121,12 +125,18 @@ `state(def-wallet `(snag 0 xs)) :: %req-pay-address - ?< =(src.bowl payee.act) :: can't pay yourself + :: TODO: add whitelisting here instead of comet block + :: can't pay yourself; comets can't pay (could spam requests) + :: forwards poke to payee if payee isn't us + :: wire is /payer/value/timestamp + :: + ?< =(src.bowl payee.act) + ?< ?=(%pawn (clan:title src.bowl)) :_ state - ?. =(payee.act our.bowl) :: forward poke to payee + ?. =(payee.act our.bowl) ~[(poke-wallet-hook payee.act act)] ?~ def-wallet ~|("btc-wallet-hook: no def-wallet set" !!) - :~ %+ poke-wallet-store /[(scot %p src.bowl)] + :~ %+ poke-wallet-store /[(scot %p src.bowl)]/[(scot %ud value.act)] [%generate-address u.def-wallet %0] == :: @@ -186,15 +196,25 @@ == :: ++ handle-wallet-store-update - |= upd=update:bws + |= [=wire upd=update:bws] ^- (quip card _state) ?- -.upd %generate-address - :: TODO: add to piym - :: TODO: send to requesting wallet-hook - `state + ?> ?=([@ @ @ *] wire) + =/ value=sats (slav %ud +<.wire) + =/ payer=ship (slav %p -.wire) + :: moons go in a jar with parent as the key + :: this will let me implement moon rate-limiting + :: + =/ fam=ship + ?: =(%earl (clan:title payer)) + (sein:title our.bowl now.bowl payer) + payer + :- ~[(poke-wallet-hook payer [%pay-address address.upd payer value])] + state(piym (~(add ja piym) fam [address.upd payer value])) :: %scan-done + :: TODO: update def-wallet if none set `state == :: diff --git a/sur/btc-wallet-hook.hoon b/sur/btc-wallet-hook.hoon index 7d370ce99d..213d2522cb 100644 --- a/sur/btc-wallet-hook.hoon +++ b/sur/btc-wallet-hook.hoon @@ -31,7 +31,7 @@ $% [%set-provider provider=ship] [%set-default-wallet ~] [%req-pay-address payee=ship value=sats] - [%pay-address payer=ship value=sats =address] + [%pay-address =address payer=ship value=sats] [%force-retry ~] == --