From 95f2a8dab61aa238e3a2244095f01a66b888fba8 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 21 Aug 2024 11:33:17 +1000 Subject: [PATCH] Do not access ScriptBuf inner from builder The `Builder` is staying in `bitcoin` while the `ScriptBuf` is moving to `primitives`, so we cannot access the inner field of `ScriptBuf`. Use the new `as_byte_vec` hack to mutate the inner `ScriptBuf` field. --- bitcoin/src/blockdata/script/builder.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitcoin/src/blockdata/script/builder.rs b/bitcoin/src/blockdata/script/builder.rs index 6ed1456bc..c8465df9f 100644 --- a/bitcoin/src/blockdata/script/builder.rs +++ b/bitcoin/src/blockdata/script/builder.rs @@ -7,7 +7,7 @@ use crate::locktime::absolute; use crate::opcodes::all::*; use crate::opcodes::{self, Opcode}; use crate::prelude::Vec; -use crate::script::{ScriptBufExt as _, ScriptExtPriv as _}; +use crate::script::{ScriptBufExt as _, ScriptBufExtPriv as _, ScriptExtPriv as _}; use crate::Sequence; /// An Object which can be used to construct a script piece by piece. @@ -82,7 +82,7 @@ impl Builder { // "duplicated code" because we need to update `1` field match opcode_to_verify(self.1) { Some(opcode) => { - (self.0).0.pop(); + (self.0).as_byte_vec().pop(); self.push_opcode(opcode) } None => self.push_opcode(OP_VERIFY),