mirror of
https://github.com/urbit/shrub.git
synced 2024-12-19 16:51:42 +03:00
sighash-witness works
This commit is contained in:
parent
a4901b7efa
commit
efdcdf0fdc
@ -191,7 +191,10 @@ Native P2WPKH
|
||||
|
||||
=output0 (output:tx:btcs [[%bech32 'bc1qs2qtxl0n0rdenan0shy457p6w6k85m2e36f7ze'] 112.340.000])
|
||||
=output1 (output:tx:btcs [[%bech32 'bc1q800y9klw0exmu63pkt2sechszel64q2enddkt4'] 223.450.000])
|
||||
=utx (unsigned:tx:btcs [~[input0 input1] ~[output0 output1]])
|
||||
=utx (unsigned:tx:btcs [1 0x11 ~[input0 input1] ~[output0 output1]])
|
||||
|
||||
(~(sighash unsigned-tx:btc utx) 1)
|
||||
:: gives [wid=32 dat=0xc37a.f311.16d1.b27c.af68.aae9.e3ac.82f1.4779.2901.4d5b.9176.57d0.eb49.478c.b670]
|
||||
```
|
||||
|
||||
## cutting off the last 20 bytes (for bech32 address outputs):
|
||||
|
30
lib/btc.hoon
30
lib/btc.hoon
@ -104,15 +104,39 @@
|
||||
(turn inputs.ut sequence-buffer)
|
||||
=/ outputs=byts
|
||||
%- concat-as-byts (turn outputs.ut outputs-buffer)
|
||||
:: all the variables
|
||||
:: Hash inputs in order, as per BIP143 examples
|
||||
::
|
||||
=/ n-version=^buffer (from-atom-le 4 version.ut)
|
||||
=/ hash-prevouts=^buffer
|
||||
%- from-byts (dsha256 prevouts)
|
||||
=/ hash-sequence=^buffer
|
||||
%- from-byts (dsha256 sequences)
|
||||
=/ outpoint=^buffer
|
||||
%+ weld (from-byts tx-hash.input)
|
||||
(from-atom-le 4 witness-ver.input)
|
||||
=/ script-code=^buffer
|
||||
%- to-script-pubkey
|
||||
(slag 2 (from-byts script-pubkey.input))
|
||||
=/ amount=^buffer
|
||||
(from-atom-le 8 value.input)
|
||||
=/ n-sequence=^buffer (sequence-buffer input)
|
||||
~& > [prevouts=(dsha256 prevouts) sequences=(dsha256 sequences) outputs=(dsha256 outputs)]
|
||||
[0 0x0]
|
||||
=/ hash-outputs=^buffer
|
||||
%- from-byts (dsha256 outputs)
|
||||
=/ n-locktime=^buffer (from-atom-le 4 locktime.ut)
|
||||
=/ n-hashtype=^buffer (from-atom-le 4 1)
|
||||
%- dsha256
|
||||
%- concat-as-byts
|
||||
:~ n-version
|
||||
hash-prevouts
|
||||
hash-sequence
|
||||
outpoint
|
||||
script-code
|
||||
amount
|
||||
n-sequence
|
||||
hash-outputs
|
||||
n-locktime
|
||||
n-hashtype
|
||||
==
|
||||
::
|
||||
++ sighash-legacy
|
||||
|= =input:tx ^- hash
|
||||
|
@ -9,7 +9,9 @@
|
||||
++ tx
|
||||
|%
|
||||
+$ unsigned
|
||||
$: inputs=(list input)
|
||||
$: version=@
|
||||
locktime=@
|
||||
inputs=(list input)
|
||||
outputs=(list output)
|
||||
==
|
||||
+$ input
|
||||
@ -35,3 +37,4 @@
|
||||
++ op-checksig 172
|
||||
--
|
||||
--
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user