mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-12 15:01:38 +03:00
hdkey includes pubkey
This commit is contained in:
parent
16d97f4084
commit
55a9728c80
4
PSBT.md
4
PSBT.md
@ -22,7 +22,7 @@ bitcoin-cli -rpcuser=__cookie__ -rpcpassword=9e0ca21c70d6b7307b750c8012d12df04ef
|
||||
=btc -build-file %/lib/btc/hoon
|
||||
=psbt 'cHNidP8BAKACAAAAAqsJSaCMWvfEm4IS9Bfi8Vqz9cM9zxU4IagTn4d6W3vkAAAAAAD+////qwlJoIxa98SbghL0F+LxWrP1wz3PFTghqBOfh3pbe+QBAAAAAP7///8CYDvqCwAAAAAZdqkUdopAu9dAy+gdmI5x3ipNXHE5ax2IrI4kAAAAAAAAGXapFG9GILVT+glechue4O/p+gOcykWXiKwAAAAAAAEHakcwRAIgR1lmF5fAGwNrJZKJSGhiGDR9iYZLcZ4ff89X0eURZYcCIFMJ6r9Wqk2Ikf/REf3xM286KdqGbX+EhtdVRs7tr5MZASEDXNxh/HupccC1AaZGoqg7ECy0OIEhfKaC3Ibi1z+ogpIAAQEgAOH1BQAAAAAXqRQ1RebjO4MsRwUPJNPuuTycA5SLx4cBBBYAFIXRNTfy4mVAWjTbr6nj3aAfuCMIAAAA'
|
||||
|
||||
(parse:^psbt:btc psbt)
|
||||
(parse:pbt:btc psbt)
|
||||
```
|
||||
|
||||
## Make an HD Path
|
||||
@ -53,7 +53,7 @@ Maps:
|
||||
- Non Witness TX: 82 byte input tx
|
||||
- Wallet Derivation path.
|
||||
* Key: {0x6}|{33byte pubkey}
|
||||
* Val: {4byte master xpub fingerprint}|{17byte HD path**
|
||||
* Val: {4byte master xpub fingerprint}|{17byte HD path}
|
||||
3. skips the main output for some reason, even though it's in raw tx hex.
|
||||
*skips* = double separator, I think
|
||||
**we can skip an ouput if the path is on someone else's ship**
|
||||
|
@ -3,6 +3,7 @@
|
||||
## xpub
|
||||
xpub1 is from mnemonic from PRIVATE.scratch
|
||||
```
|
||||
=bl -build-file %/lib/btc-wallet-store/hoon
|
||||
=xpub1 'zpub6r8dKyWJ31XF6n69KKeEwLjVC5ruqAbiJ4QCqLsrV36Mvx9WEjUaiPNPGFLHNCCqgCdy6iZC8ZgHsm6a1AUTVBMVbKGemNcWFcwBGSjJKbD'
|
||||
=xpub2 'xpub6D7yaZieZEeG617UcKXDhbsDeso6bmxSAiGWkvkASoiwcjaRtrH5HeNRnDT25s7zmxYzj6MtFe32dVqcf9YcBKKgn9THHjwn2uSjkvobK4e'
|
||||
=bl -build-file %/lib/btc-wallet-store/hoon
|
||||
|
@ -156,7 +156,8 @@
|
||||
[~[(send-update [%generate-txbu xpub.act u.tb])] state]
|
||||
=/ [addr=address:btc =idx w=walt]
|
||||
~(nixt-address wad u.uw %1)
|
||||
=+ new-txbu=(~(add-output txb u.tb) addr u.chng `[fprint.w bipt.w %1 idx])
|
||||
=/ new-txbu=txbu
|
||||
(~(add-output txb u.tb) addr u.chng `(~(hdkey wad w %1) idx))
|
||||
:_ state(walts (~(put by walts) xpub.act w))
|
||||
:~ (send-update [%generate-txbu xpub.act new-txbu])
|
||||
%+ send-request ~[requests-path]
|
||||
|
@ -74,6 +74,11 @@
|
||||
pub:(derive-public:(derive-public:wilt.w (@ chyg)) idx)
|
||||
[(met 3 pk) pk]
|
||||
::
|
||||
++ hdkey
|
||||
|= =idx:btc
|
||||
^- hdkey:btc
|
||||
[fprint.w (~(pubkey wad w chyg) idx) bipt.w chyg idx]
|
||||
::
|
||||
++ mk-address
|
||||
|= =idx:btc
|
||||
^- address:btc
|
||||
@ -241,7 +246,8 @@
|
||||
payee
|
||||
(total-vbytes is)
|
||||
%+ turn is
|
||||
|=(i=input [utxo.i ~ [fprint.w bipt.w chyg.i idx.i]])
|
||||
|= i=input
|
||||
[utxo.i ~ (~(hdkey wad w chyg.i) idx.i)]
|
||||
txos
|
||||
==
|
||||
--
|
||||
|
58
lib/btc.hoon
58
lib/btc.hoon
@ -62,25 +62,44 @@
|
||||
++ globals
|
||||
|= =rawtx
|
||||
^- map:psbt
|
||||
*map:psbt
|
||||
++ inputs
|
||||
|= (list in:psbt)
|
||||
:~ [[1 0x0] rawtx]
|
||||
==
|
||||
::
|
||||
++ input
|
||||
|= i=in:psbt
|
||||
^- map:psbt
|
||||
*map:psbt
|
||||
++ outputs
|
||||
|= (list out:psbt)
|
||||
:~ [[1 0x0] rawtx.i]
|
||||
(witness-tx i)
|
||||
(hdkey %input hdkey.i)
|
||||
==
|
||||
::
|
||||
++ output
|
||||
|= =out:psbt
|
||||
^- map:psbt
|
||||
*map:psbt
|
||||
--
|
||||
?~ hk.out ~
|
||||
:~ (hdkey %output u.hk.out)
|
||||
==
|
||||
::
|
||||
++ witness-tx
|
||||
|= i=in:psbt
|
||||
^- keyval:psbt
|
||||
:- [1 0x1]
|
||||
%- cat:byt
|
||||
:~ (flip:byt 4^value.utxo.i)
|
||||
1^0x16
|
||||
2^0x14
|
||||
(hash-160 dat.pubkey.hdkey.i)
|
||||
==
|
||||
::
|
||||
++ hdkey
|
||||
|= [pubkey=bytc =target:psbt h=^hdkey]
|
||||
|= [=target:psbt h=^hdkey]
|
||||
^- keyval:psbt
|
||||
=/ typ=@ux
|
||||
?- target
|
||||
%input 0x6
|
||||
%output 0x2
|
||||
==
|
||||
:- (cat:byt ~[1^typ pubkey])
|
||||
:- (cat:byt ~[1^typ pubkey.h])
|
||||
%- cat:byt
|
||||
:~ fprint.h
|
||||
%- to-byts:buf
|
||||
@ -91,11 +110,14 @@
|
||||
==
|
||||
(flip:byt [(met 3 idx.h) idx.h])
|
||||
==
|
||||
--
|
||||
:: +encode: make base64 cord of PSBT
|
||||
::
|
||||
++ encode
|
||||
|= [=rawtx =txid inputs=(list in:psbt) outputs=(list out:psbt)]
|
||||
^- cord
|
||||
|= [=rawtx =txid inputs=(list in:psbt) outputs=(list out:psbt)]
|
||||
^- cord
|
||||
:: (globals rawtx)
|
||||
|
||||
:: TODO
|
||||
:: make global map
|
||||
:: raw tx hex
|
||||
@ -104,18 +126,6 @@
|
||||
:: parse to hex
|
||||
:: encode as base64!
|
||||
*cord
|
||||
:: +create: make base64 cord of PSBT
|
||||
::
|
||||
++ create
|
||||
|= [=rawtx =txid inputs=(list in:psbt) outputs=(list out:psbt)]
|
||||
^- cord
|
||||
:: TODO
|
||||
:: make global map
|
||||
:: turn each input and output into a map (or ~)
|
||||
:: put the 0x0 separator between all
|
||||
:: parse to hex
|
||||
:: encode as base64!
|
||||
*cord
|
||||
::
|
||||
++ parse
|
||||
|= psbt-base64=cord
|
||||
|
@ -10,7 +10,7 @@
|
||||
+$ bipt $?(%44 %49 %84)
|
||||
+$ chyg $?(%0 %1)
|
||||
+$ idx @ud
|
||||
+$ hdkey [=fprint =bipt =chyg =idx]
|
||||
+$ hdkey [=fprint pubkey=bytc =bipt =chyg =idx]
|
||||
+$ sats @ud
|
||||
+$ vbytes @ud
|
||||
+$ bytc [wid=@ dat=@ux]
|
||||
@ -20,7 +20,7 @@
|
||||
+$ txid hash256
|
||||
+$ rawtx bytc
|
||||
+$ buffer (list @ux)
|
||||
+$ utxo [pos=@ =txid height=@ value=sats recvd=(unit @da)]
|
||||
+$ utxo [pos=@ =txid height=@ value=sats recvd=(unit @da)]
|
||||
++ address-info
|
||||
$: =address
|
||||
confirmed-value=sats
|
||||
@ -61,7 +61,7 @@
|
||||
--
|
||||
++ psbt
|
||||
|%
|
||||
+$ in [pubkey=bytc =utxo =rawtx =hdkey]
|
||||
+$ in [=utxo =rawtx =hdkey]
|
||||
+$ out [=address hk=(unit hdkey)]
|
||||
+$ target $?(%input %output)
|
||||
+$ keyval [key=bytc val=bytc]
|
||||
|
Loading…
Reference in New Issue
Block a user