From ecb40418e6c1fe1068ea20abfb2887e55cc921eb Mon Sep 17 00:00:00 2001 From: timlucmiptev Date: Tue, 8 Dec 2020 14:47:51 +0200 Subject: [PATCH] type framework for parse --- lib/btc.hoon | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/btc.hoon b/lib/btc.hoon index 55d4577da..f93e3c493 100644 --- a/lib/btc.hoon +++ b/lib/btc.hoon @@ -68,21 +68,22 @@ :: ++ psbt |% -:: ++ parse -:: |= psbt=cord -:: ^- (list ) + ++ parse + |= psbt-base64=cord + ^- (list (list keyval:^psbt)) + ~[~] :: TODO: :: - get into a buffer :: loop through using next-pair :: every time there's a separator, close the prior on :: +txid: extract txid from a valid PSBT ++ get-txid - |= psbt=cord + |= psbt-base64=cord ^- txid =/ tx=btc-byts %- raw-tx %+ slag 5 - (to-buffer psbt) + (to-buffer psbt-base64) =/ hash=btc-byts %- flip-byts %- sha256 @@ -120,10 +121,10 @@ (to-byts:buffer v) :: ++ to-buffer - |= psbt=cord + |= psbt-base64=cord ^- ^buffer ~| "Invalid PSBT" - =+ p=(de:base64 psbt) + =+ p=(de:base64 psbt-base64) ?~ p !! =/ bigend=@ux (swp 3 q.u.p) (from-byts:buffer [(met 3 bigend) bigend])