@@ -91,6 +91,41 @@ describe("BIP-0322", function () {
9191 } ) ;
9292 } , / B I P - 0 3 2 2 P S B T m u s t h a v e v e r s i o n 0 / ) ;
9393 } ) ;
94+
95+ it ( "should store and retrieve BIP322 message via proprietary field" , function ( ) {
96+ const psbt = fixedScriptWallet . BitGoPsbt . createEmpty ( "testnet" , walletKeys , { version : 0 } ) ;
97+
98+ bip322 . addBip322Input ( psbt , {
99+ message : "Hello, BitGo!" ,
100+ scriptId : { chain : 10 , index : 0 } ,
101+ rootWalletKeys : walletKeys ,
102+ } ) ;
103+
104+ assert . strictEqual ( bip322 . getBip322Message ( psbt , 0 ) , "Hello, BitGo!" ) ;
105+ } ) ;
106+
107+ it ( "should store different messages for multiple inputs" , function ( ) {
108+ const psbt = fixedScriptWallet . BitGoPsbt . createEmpty ( "testnet" , walletKeys , { version : 0 } ) ;
109+
110+ bip322 . addBip322Input ( psbt , {
111+ message : "Message A" ,
112+ scriptId : { chain : 10 , index : 0 } ,
113+ rootWalletKeys : walletKeys ,
114+ } ) ;
115+ bip322 . addBip322Input ( psbt , {
116+ message : "Message B" ,
117+ scriptId : { chain : 10 , index : 1 } ,
118+ rootWalletKeys : walletKeys ,
119+ } ) ;
120+
121+ assert . strictEqual ( bip322 . getBip322Message ( psbt , 0 ) , "Message A" ) ;
122+ assert . strictEqual ( bip322 . getBip322Message ( psbt , 1 ) , "Message B" ) ;
123+ } ) ;
124+
125+ it ( "should throw for input index out of bounds in getBip322Message" , function ( ) {
126+ const psbt = fixedScriptWallet . BitGoPsbt . createEmpty ( "testnet" , walletKeys , { version : 0 } ) ;
127+ assert . throws ( ( ) => bip322 . getBip322Message ( psbt , 0 ) , / o u t o f b o u n d s / ) ;
128+ } ) ;
94129 } ) ;
95130
96131 describe ( "sign and verify per-input" , function ( ) {
0 commit comments