diff --git a/bippy-scratch.md b/bippy-scratch.md index 2356a23545..1ad6cefbcb 100644 --- a/bippy-scratch.md +++ b/bippy-scratch.md @@ -3,11 +3,11 @@ The below requires norsyr's fix to `decompress-point` in order to work. ## Set Credentials and Ping Servers ``` -=rpc-pass '57669fe0365412f8b2152cba2aa6fbada8a9483f9f01fee24b05ed407b1c1635' +=rpc-pass '22b159ae3ebfdc3404b446fc61df4760de0fece271586dfb5039e1260cb15775' :btc-provider|command [%set-credentials [rpc-url='http://localhost:8332' rpc-user='__cookie__' rpc-pass] [rpc-url='http://localhost:50002']] :btc-provider|rpc-action [%brpc %get-block-count ~] -:btc-provider|rpc-action [%erpc %get-address-balance [%bech32 'bc1q59u5epktervh6fxqay2dlph0wxu9hjnx6v8n66']] +:btc-provider|rpc-action [%erpc %get-address-utxos [%bech32 'bc1q59u5epktervh6fxqay2dlph0wxu9hjnx6v8n66']] ``` ## Transactions diff --git a/lib/electrum-rpc-http.hoon b/lib/electrum-rpc-http.hoon index bb95cded76..2faad087c9 100644 --- a/lib/electrum-rpc-http.hoon +++ b/lib/electrum-rpc-http.hoon @@ -19,12 +19,17 @@ ++ request-to-http |= [endpoint=@t req=request:electrum:rpc] ^- request:http + %- http-request ?- -.req %get-address-balance - %- http-request %^ cat 3 (cat 3 endpoint '/addresses/balance/') (address-to-cord address.req) + :: + %get-address-utxos + %^ cat 3 + (cat 3 endpoint '/addresses/listunspent/') + (address-to-cord address.req) == -- -- diff --git a/sur/btc-provider.hoon b/sur/btc-provider.hoon index 6107b52ec6..fb9bdd4d8d 100644 --- a/sur/btc-provider.hoon +++ b/sur/btc-provider.hoon @@ -5,12 +5,13 @@ +$ credentials [bc=btc-credentials ec=electrum-credentials] +$ status [creds=credentials connected=? clients=(set ship)] +$ action - $% [%get-balance addresses=(set address)] - [%get-transactions addresses=(set address)] + $% [%get-address-info =address] == +$ response $% [%block-count count=@] - [%balance (set [=address balance=sats])] + [%get-address-info info=address-info] + [%get-balance (set [=address balance=sats])] + [%get-transactions ~] == +$ update :: sub updates from /clients path (connection etc.) $% [%status connected=?] @@ -30,6 +31,7 @@ |% +$ request $% [%get-address-balance =address] + [%get-address-utxos =address] == -- ++ bitcoin-core diff --git a/sur/btc-wallet.hoon b/sur/btc-wallet.hoon index feeeab015f..3a9cf90ac7 100644 --- a/sur/btc-wallet.hoon +++ b/sur/btc-wallet.hoon @@ -10,3 +10,4 @@ :: wallets :: how many should we store? :: seems like a list or a map keyed by xpub + diff --git a/sur/btc.hoon b/sur/btc.hoon index fe0d591040..8094ebba04 100644 --- a/sur/btc.hoon +++ b/sur/btc.hoon @@ -8,8 +8,12 @@ +$ hash160 [wid=%20 dat=@ux] +$ hash ?(hash256 hash160) +$ buffer (list @ux) ++$ utxo [pos=@ tx-hash=hash256 block-height=@ value=sats] ++ address-info $: =address + confirmed-value=sats + unconfirmed-value=sats + utxos=(set utxo) == ++ tx |% @@ -20,7 +24,7 @@ outputs=(list output) == +$ input - $: tx-hash=byts + $: tx-hash=hash256 tx-index=@ witness-ver=@ sequence=byts @@ -32,6 +36,7 @@ +$ output $: =address value=sats + == -- ++ ops