From 4b61c30e55342c82929fd6b6104a70a82e6c02a4 Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Tue, 9 Feb 2021 16:20:11 +0400 Subject: [PATCH] %delete-wallet support --- app/btc-wallet-hook.hoon | 12 ++++++++++-- app/btc-wallet-store.hoon | 4 ++++ sur/btc-wallet-hook.hoon | 3 ++- sur/btc-wallet-store.hoon | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/btc-wallet-hook.hoon b/app/btc-wallet-hook.hoon index bcf3459cd..f3e6e14d1 100644 --- a/app/btc-wallet-hook.hoon +++ b/app/btc-wallet-hook.hoon @@ -141,8 +141,16 @@ :: %set-default-wallet =/ xs=(list xpub) scry-scanned - ?. (gth (lent xs) 0) `state - `state(def-wallet `(snag 0 xs)) + =/ i=(unit @) (find ~[xpub.comm] xs) + ?~ i `state + `state(def-wallet `(snag u.i xs)) + :: + %delete-wallet + :- ~[(poke-store [%delete-wallet xpub.comm])] + ?~ def-wallet state + ?. =(u.def-wallet xpub.comm) state + state(def-wallet ~) + :: TODO if wallet is xpub.comm, clear :: :: %req-pay-address :: overwrites any payment being built currently diff --git a/app/btc-wallet-store.hoon b/app/btc-wallet-store.hoon index 167655690..49685404c 100644 --- a/app/btc-wallet-store.hoon +++ b/app/btc-wallet-store.hoon @@ -111,6 +111,10 @@ =/ w=walt (from-xpub +.act) =. walts (~(put by walts) xpub.act w) (init-batches xpub.act (dec max-gap.w)) + :: + %delete-wallet + `state(walts (~(del by walts) xpub.act)) + :: :: TODO :: if blank address we're watching gets a value :: "blank" = unused diff --git a/sur/btc-wallet-hook.hoon b/sur/btc-wallet-hook.hoon index 58dc89cdb..f870915b0 100644 --- a/sur/btc-wallet-hook.hoon +++ b/sur/btc-wallet-hook.hoon @@ -28,7 +28,8 @@ :: +$ command $% [%set-provider provider=ship =network] - [%set-default-wallet ~] + [%set-default-wallet =xpub] + [%delete-wallet =xpub] [%clear-poym ~] [%force-retry ~] [%req-pay-address payee=ship value=sats feyb=(unit sats)] diff --git a/sur/btc-wallet-store.hoon b/sur/btc-wallet-store.hoon index 2ac6087b0..2b45e9ff9 100644 --- a/sur/btc-wallet-store.hoon +++ b/sur/btc-wallet-store.hoon @@ -90,6 +90,7 @@ :: +$ action $% [%add-wallet =xpub =fprint scan-to=(unit scon) max-gap=(unit @ud) confs=(unit @ud)] + [%delete-wallet =xpub] [%address-info =xpub =chyg =idx utxos=(set utxo) used=? block=@ud] [%tx-info =info:tx block=@ud] [%generate-address =xpub =chyg =pmet]