@@ -42,7 +42,7 @@ pub enum ProprietaryKeySubtype {
4242 Musig2PartialSig = 0x03 ,
4343 PayGoAddressAttestationProof = 0x04 ,
4444 Bip322Message = 0x05 ,
45- WasmUtxoVersion = 0x06 ,
45+ WasmUtxoSignedWith = 0x06 ,
4646}
4747
4848impl ProprietaryKeySubtype {
@@ -54,7 +54,7 @@ impl ProprietaryKeySubtype {
5454 0x03 => Some ( ProprietaryKeySubtype :: Musig2PartialSig ) ,
5555 0x04 => Some ( ProprietaryKeySubtype :: PayGoAddressAttestationProof ) ,
5656 0x05 => Some ( ProprietaryKeySubtype :: Bip322Message ) ,
57- 0x06 => Some ( ProprietaryKeySubtype :: WasmUtxoVersion ) ,
57+ 0x06 => Some ( ProprietaryKeySubtype :: WasmUtxoSignedWith ) ,
5858 _ => None ,
5959 }
6060 }
@@ -187,25 +187,14 @@ impl WasmUtxoVersionInfo {
187187 Ok ( Self { version, git_hash } )
188188 }
189189
190- /// Convert to proprietary key-value pair for PSBT global fields
191- pub fn to_proprietary_kv ( & self ) -> ( ProprietaryKey , Vec < u8 > ) {
192- let key = ProprietaryKey {
193- prefix : BITGO . to_vec ( ) ,
194- subtype : ProprietaryKeySubtype :: WasmUtxoVersion as u8 ,
195- key : vec ! [ ] , // Empty key data - only one version per PSBT
196- } ;
197- ( key, self . to_bytes ( ) )
198- }
199-
200- /// Create from proprietary key-value pair
201- pub fn from_proprietary_kv ( key : & ProprietaryKey , value : & [ u8 ] ) -> Result < Self , String > {
202- if key. prefix . as_slice ( ) != BITGO {
203- return Err ( "Not a BITGO proprietary key" . to_string ( ) ) ;
204- }
205- if key. subtype != ProprietaryKeySubtype :: WasmUtxoVersion as u8 {
206- return Err ( "Not a WasmUtxoVersion proprietary key" . to_string ( ) ) ;
207- }
208- Self :: from_bytes ( value)
190+ /// Build a (ProprietaryKey, value) pair for per-input "signed-with" storage
191+ pub fn build_key_value ( ) -> ( ProprietaryKey , Vec < u8 > ) {
192+ BitGoKeyValue :: new (
193+ ProprietaryKeySubtype :: WasmUtxoSignedWith ,
194+ vec ! [ ] ,
195+ WasmUtxoVersionInfo :: from_build_info ( ) . to_bytes ( ) ,
196+ )
197+ . to_key_value ( )
209198 }
210199}
211200
@@ -333,17 +322,15 @@ mod tests {
333322 }
334323
335324 #[ test]
336- fn test_version_info_proprietary_kv ( ) {
337- let version_info =
338- WasmUtxoVersionInfo :: new ( "0.0.2" . to_string ( ) , "abc123def456" . to_string ( ) ) ;
339-
340- let ( key, value) = version_info. to_proprietary_kv ( ) ;
325+ fn test_version_info_build_key_value ( ) {
326+ let ( key, value) = WasmUtxoVersionInfo :: build_key_value ( ) ;
341327 assert_eq ! ( key. prefix, b"BITGO" ) ;
342- assert_eq ! ( key. subtype, ProprietaryKeySubtype :: WasmUtxoVersion as u8 ) ;
328+ assert_eq ! ( key. subtype, ProprietaryKeySubtype :: WasmUtxoSignedWith as u8 ) ;
343329 let empty_vec: Vec < u8 > = vec ! [ ] ;
344330 assert_eq ! ( key. key, empty_vec) ;
345331
346- let deserialized = WasmUtxoVersionInfo :: from_proprietary_kv ( & key, & value) . unwrap ( ) ;
347- assert_eq ! ( deserialized, version_info) ;
332+ // The value should round-trip through from_bytes
333+ let info = WasmUtxoVersionInfo :: from_bytes ( & value) . unwrap ( ) ;
334+ assert_eq ! ( info, WasmUtxoVersionInfo :: from_build_info( ) ) ;
348335 }
349336}
0 commit comments