@@ -48,6 +48,14 @@ pub trait PsbtAccess {
4848 self . psbt ( ) . proprietary . get ( key) . cloned ( )
4949 }
5050
51+ fn delete_global_unknown_kv ( & mut self , key : raw:: Key ) {
52+ self . psbt_mut ( ) . unknown . remove ( & key) ;
53+ }
54+
55+ fn delete_global_proprietary_kv ( & mut self , key : raw:: ProprietaryKey ) {
56+ self . psbt_mut ( ) . proprietary . remove ( & key) ;
57+ }
58+
5159 // -------------------------------------------------------------------------
5260 // Per-input KV accessors
5361 // -------------------------------------------------------------------------
@@ -112,6 +120,32 @@ pub trait PsbtAccess {
112120 Ok ( self . psbt ( ) . inputs [ index] . proprietary . get ( key) . cloned ( ) )
113121 }
114122
123+ fn delete_input_unknown_kv ( & mut self , index : usize , key : raw:: Key ) -> Result < ( ) , String > {
124+ let len = self . psbt ( ) . inputs . len ( ) ;
125+ if index >= len {
126+ return Err ( format ! (
127+ "input index {index} out of bounds (have {len} inputs)"
128+ ) ) ;
129+ }
130+ self . psbt_mut ( ) . inputs [ index] . unknown . remove ( & key) ;
131+ Ok ( ( ) )
132+ }
133+
134+ fn delete_input_proprietary_kv (
135+ & mut self ,
136+ index : usize ,
137+ key : raw:: ProprietaryKey ,
138+ ) -> Result < ( ) , String > {
139+ let len = self . psbt ( ) . inputs . len ( ) ;
140+ if index >= len {
141+ return Err ( format ! (
142+ "input index {index} out of bounds (have {len} inputs)"
143+ ) ) ;
144+ }
145+ self . psbt_mut ( ) . inputs [ index] . proprietary . remove ( & key) ;
146+ Ok ( ( ) )
147+ }
148+
115149 // -------------------------------------------------------------------------
116150 // Per-output KV accessors
117151 // -------------------------------------------------------------------------
@@ -178,6 +212,32 @@ pub trait PsbtAccess {
178212 Ok ( self . psbt ( ) . outputs [ index] . proprietary . get ( key) . cloned ( ) )
179213 }
180214
215+ fn delete_output_unknown_kv ( & mut self , index : usize , key : raw:: Key ) -> Result < ( ) , String > {
216+ let len = self . psbt ( ) . outputs . len ( ) ;
217+ if index >= len {
218+ return Err ( format ! (
219+ "output index {index} out of bounds (have {len} outputs)"
220+ ) ) ;
221+ }
222+ self . psbt_mut ( ) . outputs [ index] . unknown . remove ( & key) ;
223+ Ok ( ( ) )
224+ }
225+
226+ fn delete_output_proprietary_kv (
227+ & mut self ,
228+ index : usize ,
229+ key : raw:: ProprietaryKey ,
230+ ) -> Result < ( ) , String > {
231+ let len = self . psbt ( ) . outputs . len ( ) ;
232+ if index >= len {
233+ return Err ( format ! (
234+ "output index {index} out of bounds (have {len} outputs)"
235+ ) ) ;
236+ }
237+ self . psbt_mut ( ) . outputs [ index] . proprietary . remove ( & key) ;
238+ Ok ( ( ) )
239+ }
240+
181241 fn remove_input ( & mut self , index : usize ) -> Result < ( ) , String > {
182242 let psbt = self . psbt_mut ( ) ;
183243 if index >= psbt. inputs . len ( ) {
0 commit comments