From d8bd3871b87eed414ef20b4cd2c09db49434b52b Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Tue, 8 Dec 2020 19:51:14 +0200 Subject: [PATCH] integrated fingerprint --- WALLET.scratch.md | 4 ++-- lib/btc-wallet-store.hoon | 18 ++++++++++++------ lib/btc.hoon | 8 +++++++- sur/btc-wallet-store.hoon | 6 +++--- sur/btc.hoon | 2 ++ 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/WALLET.scratch.md b/WALLET.scratch.md index acc1fd71b..02a5773bd 100644 --- a/WALLET.scratch.md +++ b/WALLET.scratch.md @@ -10,14 +10,14 @@ xpub1 is from mnemonic from PRIVATE.scratch ### get address at indices ``` -=walt1 (from-xpub:bl xpub1 ~ ~) +=walt1 (from-xpub:bl xpub1 [%4 0x5566.7788] ~ ~ ~) (~(mk-address wad:bl walt1 %0) 0) :: gives [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] ``` ### update address data ``` -=walt1 (from-xpub:bl xpub1 ~ ~) +=walt1 (from-xpub:bl xpub1 ~ ~ ~) (~(mk-address wad:bl walt1 %0) 0) :: gives bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc =walt1 (~(watch-address wad:bl walt1 %0) [%bech32 'bc1q0adfj7ur750hjwufzzlfj5ytqzsnd7fz9fjuzc'] [%0 0 ~]) diff --git a/lib/btc-wallet-store.hoon b/lib/btc-wallet-store.hoon index 2a09f13c6..3f2913de8 100644 --- a/lib/btc-wallet-store.hoon +++ b/lib/btc-wallet-store.hoon @@ -54,25 +54,31 @@ t(txos [txo txos.t]) :: ++ to-psbt + |= w=walt ^- cord '' :: TODO + :: for each txi, get the pubkey from the hdkey :: get a list of map:psbt:btc - -- :: wad: door for processing walts (wallets) -:: parameterized on a walt and it's chyg account +:: parameterized on a walt and it's chyg account :: ++ wad |_ [w=walt =chyg] + ++ pubkey + |= =idx:btc + ^- btc-byts:btc + =/ pk=@ux + %- compress-point:ecc + pub:(derive-public:(derive-public:wilt.w (@ chyg)) idx) + [(met 3 pk) pk] + :: ++ mk-address |= =idx:btc ^- address:btc - =/ pubkey=@ux - %- compress-point:ecc - pub:(derive-public:(derive-public:wilt.w (@ chyg)) idx) ?: ?=(%bip84 bipt.w) - (need (encode-pubkey:bech32:btc %main pubkey)) + (need (encode-pubkey:bech32:btc %main dat:(pubkey idx))) ~|("legacy addresses not supported yet " !!) :: generates and watches the next available address :: diff --git a/lib/btc.hoon b/lib/btc.hoon index d38fb2947..d191230b9 100644 --- a/lib/btc.hoon +++ b/lib/btc.hoon @@ -68,9 +68,15 @@ :: ++ psbt |% + :: +create: make base64 cord of PSBT + :: + ++ create + |= [=rawtx =txid inputs=(list in:^psbt) outputs=(list out:^psbt)] + ^- cord + *cord :: ++ hd-path - |= [pubkey=btc-byts =target:^psbt =hdkey] + |= [pubkey=btc-byts =target:^psbt =hdkey] ^- keyval:^psbt =/ k=btc-byts %- to-byts:buffer diff --git a/sur/btc-wallet-store.hoon b/sur/btc-wallet-store.hoon index 81862c2f3..4adde5f81 100644 --- a/sur/btc-wallet-store.hoon +++ b/sur/btc-wallet-store.hoon @@ -26,7 +26,7 @@ :: scan-to :: max-gap: maximum number of consec blank addresses before wallet stops scanning :: confs: confirmations required (after this is hit for an address, wallet stops refreshing it) -:: +:: +$ walt $: =xpub =fprint @@ -74,7 +74,7 @@ :: scanning addresses and monitoring generated addresses :: batch: indexes to scan for a given chyg :: scans: all scans underway (batches) -:: piym-watch: any address we've been told has an incoming payment promised +:: piym-watch: any address we've been told has an incoming payment promised :: +$ batch [todo=(set idx) endpoint=idx has-used=?] +$ scans (map [xpub chyg] batch) @@ -86,7 +86,7 @@ :: TODO: document :: +$ action - $% [%add-wallet =xpub scan-to=(unit scon) max-gap=(unit @ud) confs=(unit @ud)] + $% [%add-wallet =xpub =fprint scan-to=(unit scon) max-gap=(unit @ud) confs=(unit @ud)] [%address-info =xpub =chyg =idx utxos=(set utxo) used=? block=@ud] [%tx-info =info:tx] [%generate-address =xpub =chyg =peta] diff --git a/sur/btc.hoon b/sur/btc.hoon index 5f710a558..1cdfa2d91 100644 --- a/sur/btc.hoon +++ b/sur/btc.hoon @@ -60,6 +60,8 @@ -- ++ psbt |% + +$ in [pubkey=btc-byts =utxo =rawtx =hdkey] + +$ out [=address hk=(unit hdkey)] +$ target $?(%input %output) +$ keyval [key=btc-byts val=btc-byts] +$ map (list keyval)