remove leading size byte from script-pubkey:btc

This commit is contained in:
timlucmiptev 2021-01-24 15:42:55 +02:00 committed by ixv
parent 9afea141a4
commit f58cda05a1
2 changed files with 14 additions and 6 deletions

View File

@ -61,7 +61,8 @@
(roll (turn txos.t |=(=txo value.txo)) add) (roll (turn txos.t |=(=txo value.txo)) add)
:: ::
++ tx-data ++ tx-data
|^ ^- data:tx:btc |^
^- data:tx:btc
:* (turn txis.t txi-data) :* (turn txis.t txi-data)
(turn txos.t txo-data) (turn txos.t txo-data)
0 1 `1 0 1 `1
@ -74,7 +75,8 @@
== ==
++ txo-data ++ txo-data
|= =txo |= =txo
[(script-pubkey:btc address.txo) value.txo] :* (script-pubkey:btc address.txo)
value.txo
-- --
:: ::
++ fee ++ fee

View File

@ -51,15 +51,17 @@
^- bytc ^- bytc
=/ h=bytc =/ h=bytc
?- -.address ?- -.address
:: TODO: make work for P2WSH (32 byte bech32)
%bech32 %bech32
(to-hex:bech32 address) (to-hex:bech32 address)
:: TODO: implement legacy :: TODO: implement legacy
:: https://bitcoinops.org/en/tools/calc-size/
:: above link shows how to make P2PKH and P2SH, which I'd need here
%base58 %base58
~|("base58 addresess not supported to script-pubkey yet" !!) ~|("base58 addresess not supported to script-pubkey yet" !!)
== ==
%- cat:byt %- cat:byt
:~ 1^(add 2 wid.h) :~ 1^0x0
1^0x0
1^wid.h 1^wid.h
h h
== ==
@ -82,7 +84,10 @@
|= o=output:tx |= o=output:tx
^- bytc ^- bytc
%- cat:byt %- cat:byt
~[(flip:byt 8^value.o) script-pubkey.o] :~ (flip:byt 8^value.o)
1^wid.script-pubkey.o
script-pubkey.o
==
-- --
:: ::
++ de ++ de
@ -121,7 +126,8 @@
++ output ++ output
|= b=buffer |= b=buffer
^- output:tx ^- output:tx
:- (to-byts:buf (slag 8 b)) :: slag 9 instead of 8 to skip the length byte
:- (to-byts:buf (slag 9 b))
=< dat =< dat
(flip:byt (to-byts:buf (scag 8 b))) (flip:byt (to-byts:buf (scag 8 b)))
:: ::