mirror of
https://github.com/urbit/shrub.git
synced 2024-12-20 09:21:42 +03:00
skeleton for btc-wallet-store
This commit is contained in:
parent
7b00d8c99e
commit
e03d084fb0
@ -47,7 +47,7 @@
|
|||||||
?> ?|((team:title our.bowl src.bowl) (is-client:hc src.bowl))
|
?> ?|((team:title our.bowl src.bowl) (is-client:hc src.bowl))
|
||||||
=^ cards state
|
=^ cards state
|
||||||
?: ?=(%btc-provider-command mark)
|
?: ?=(%btc-provider-command mark)
|
||||||
?> (team:title our.bowl src.bowl)
|
?> (team:title our.bowl src.bowl)
|
||||||
(handle-command:hc !<(command vase))
|
(handle-command:hc !<(command vase))
|
||||||
?+ mark (on-poke:def mark vase)
|
?+ mark (on-poke:def mark vase)
|
||||||
%btc-provider-action
|
%btc-provider-action
|
||||||
|
@ -5,28 +5,27 @@
|
|||||||
:: To Subscribers:
|
:: To Subscribers:
|
||||||
:: watched address updates
|
:: watched address updates
|
||||||
::
|
::
|
||||||
/+ dbug, default-agent
|
/- *btc-wallet-store
|
||||||
|
/+ dbug, default-agent, bip32, btc
|
||||||
|%
|
|%
|
||||||
+$ versioned-state
|
+$ versioned-state
|
||||||
$% state-0
|
$% state-0
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
+$ state-0 [%0 connected=?]
|
+$ state-0 [%0 wallets=(map tape walt)]
|
||||||
::
|
::
|
||||||
+$ card card:agent:gall
|
+$ card card:agent:gall
|
||||||
+$ command
|
|
||||||
$? %add-wallet
|
|
||||||
==
|
|
||||||
::
|
::
|
||||||
--
|
--
|
||||||
=| state-0
|
=| state-0
|
||||||
=* state -
|
=* state -
|
||||||
%- agent:dbug
|
%- agent:dbug
|
||||||
^- agent:gall
|
^- agent:gall
|
||||||
|
=<
|
||||||
|_ =bowl:gall
|
|_ =bowl:gall
|
||||||
+* this .
|
+* this .
|
||||||
des ~(. (default:shoe this command) bowl)
|
|
||||||
def ~(. (default-agent this %|) bowl)
|
def ~(. (default-agent this %|) bowl)
|
||||||
|
hc ~(. +> bowl)
|
||||||
::
|
::
|
||||||
++ on-init
|
++ on-init
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
@ -43,7 +42,13 @@
|
|||||||
++ on-poke
|
++ on-poke
|
||||||
|= [=mark =vase]
|
|= [=mark =vase]
|
||||||
^- (quip card _this)
|
^- (quip card _this)
|
||||||
`this
|
?> (team:title our.bowl src.bowl)
|
||||||
|
=^ cards state
|
||||||
|
?+ mark (on-poke:def mark vase)
|
||||||
|
%btc-wallet-store-action
|
||||||
|
(handle-action:hc !<(action vase))
|
||||||
|
==
|
||||||
|
[cards this]
|
||||||
::
|
::
|
||||||
++ on-watch on-watch:def
|
++ on-watch on-watch:def
|
||||||
++ on-leave on-leave:def
|
++ on-leave on-leave:def
|
||||||
@ -52,3 +57,26 @@
|
|||||||
++ on-arvo on-arvo:def
|
++ on-arvo on-arvo:def
|
||||||
++ on-fail on-fail:def
|
++ on-fail on-fail:def
|
||||||
--
|
--
|
||||||
|
::
|
||||||
|
|_ =bowl:gall
|
||||||
|
++ handle-action
|
||||||
|
|= act=action
|
||||||
|
^- (quip card _state)
|
||||||
|
?- -.act
|
||||||
|
%add-wallet
|
||||||
|
(add-wallet xpub.act)
|
||||||
|
==
|
||||||
|
++ add-wallet
|
||||||
|
|= xpub=tape
|
||||||
|
^- (quip card _state)
|
||||||
|
?: (~(has by wallets.state) xpub)
|
||||||
|
~& >>> "xpub already imported"
|
||||||
|
`state
|
||||||
|
=/ wallet=walt
|
||||||
|
:* (from-extended:bip32 xpub)
|
||||||
|
(xpub-type:btc xpub)
|
||||||
|
[%.n 0 *wach]
|
||||||
|
[%.n 0 *wach]
|
||||||
|
==
|
||||||
|
`state(wallets (~(put by wallets.state) xpub wallet))
|
||||||
|
--
|
||||||
|
13
gen/btc-wallet-store/action.hoon
Normal file
13
gen/btc-wallet-store/action.hoon
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
:: Sends an action to btc-wallet-store
|
||||||
|
::
|
||||||
|
:: Commands:
|
||||||
|
::
|
||||||
|
::
|
||||||
|
::
|
||||||
|
/- *btc-wallet-store
|
||||||
|
::
|
||||||
|
:- %say
|
||||||
|
|= $: [now=@da eny=@uvJ =beak]
|
||||||
|
[[act=action ~] ~]
|
||||||
|
==
|
||||||
|
[%btc-wallet-store-action act]
|
@ -1,5 +1,13 @@
|
|||||||
/- *btc
|
/- *btc
|
||||||
|%
|
|%
|
||||||
|
++ xpub-type
|
||||||
|
|= xpub=tape
|
||||||
|
^- bipt
|
||||||
|
=/ prefix=tape (scag 4 xpub)
|
||||||
|
?: =("xpub" prefix) %bip44
|
||||||
|
?: =("ypub" prefix) %bip49
|
||||||
|
?: =("zpub" prefix) %bip84
|
||||||
|
~|("invalid xpub: {<xpub>}" !!)
|
||||||
:: big endian sha256: input and output are both MSB first (big endian)
|
:: big endian sha256: input and output are both MSB first (big endian)
|
||||||
::
|
::
|
||||||
++ sha256
|
++ sha256
|
||||||
|
@ -1,22 +1,31 @@
|
|||||||
:: wallets are compatible with BIPs 44, 49, and 84
|
:: wallets are compatible with BIPs 44, 49, and 84
|
||||||
:: m / purpose' / coin_type' / account' / change / address_index
|
:: m / purpose' / coin_type' / account' / change / address_index
|
||||||
|
:: change can be 0 or 1
|
||||||
::
|
::
|
||||||
/- *btc, bip32
|
/- *btc
|
||||||
|
/+ bip32
|
||||||
|%
|
|%
|
||||||
:: wilt: copulates with thousands of indices to form addresses
|
:: addi: address with metadata inside a change path
|
||||||
|
:: wach: map for watched addresses
|
||||||
|
:: chyg: stores the state of a change/non-change path
|
||||||
|
:: wilt: stores xpub; copulates with thousands of indices to form addresses
|
||||||
:: walt: wallet metadata
|
:: walt: wallet metadata
|
||||||
::
|
::
|
||||||
|
+$ addi [idx=@ used=? utxos=(set utxo)]
|
||||||
|
+$ wach (map address addi)
|
||||||
|
+$ chyg [scanned=? next=@ =wach]
|
||||||
+$ wilt _bip32
|
+$ wilt _bip32
|
||||||
+$ walt
|
+$ walt
|
||||||
$: :: scanned: whether we've checked all addresses for prior activity
|
$: :: bipt: BIP44/49/84
|
||||||
:: ching: non-change addresses
|
:: ching: non-change addresses
|
||||||
:: chang: change addresses
|
:: chang: change addresses
|
||||||
:: watch: address -> [change address_index]
|
|
||||||
::
|
::
|
||||||
=wilt
|
=wilt
|
||||||
scanned=?
|
=bipt
|
||||||
ching=((mop @ address-info) gth)
|
ching=chyg
|
||||||
chang=((mop @ address-info) gth)
|
chang=chyg
|
||||||
watch=(map address [change=@ index=@])
|
==
|
||||||
|
+$ action
|
||||||
|
$% [%add-wallet xpub=tape]
|
||||||
==
|
==
|
||||||
--
|
--
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
+$ legacy-address $%([%legacy @uc])
|
+$ legacy-address $%([%legacy @uc])
|
||||||
+$ bech32-address $%([%bech32 cord])
|
+$ bech32-address $%([%bech32 cord])
|
||||||
+$ address ?(legacy-address bech32-address)
|
+$ address ?(legacy-address bech32-address)
|
||||||
+$ sats @ud
|
+$ bipt $?(%bip44 %bip49 %bip84)
|
||||||
|
+$ sats @ud ::
|
||||||
+$ hash256 [wid=%32 dat=@ux]
|
+$ hash256 [wid=%32 dat=@ux]
|
||||||
+$ hash160 [wid=%20 dat=@ux]
|
+$ hash160 [wid=%20 dat=@ux]
|
||||||
+$ hash ?(hash256 hash160)
|
+$ hash ?(hash256 hash160)
|
||||||
|
Loading…
Reference in New Issue
Block a user