Parsing a Bitcoin Transaction
Intro
;; --snip--
(define-read-only (parse-tx (tx (buff 4096)))
(let (
(ctx {
txbuff: tx,
index: u0,
})
(parsed-version (try! (read-uint32 ctx)))
(parsed-txins (try! (read-txins (get ctx parsed-version))))
(parsed-txouts (try! (read-txouts (get ctx parsed-txins))))
(parsed-locktime (try! (read-uint32 (get ctx parsed-txouts))))
)
;; check if it is a non-segwit transaction?
;; at least check what happens
(asserts! (is-eq (len tx) (get index (get ctx parsed-locktime)))
(err ERR-LEFTOVER-DATA)
)
(ok {
version: (get uint32 parsed-version),
ins: (get txins parsed-txins),
outs: (get txouts parsed-txouts),
locktime: (get uint32 parsed-locktime),
})
)
)Steps
Example Usage
Square Runes
Last updated
Was this helpful?