@@ -1710,6 +1710,45 @@ describe('V2 Wallet:', function () {
17101710 postProcessStub . restore ( ) ;
17111711 } ) ;
17121712
1713+ it ( 'should pass bridgingParams to tx/build for non-TSS BTC wallet' , async function ( ) {
1714+ const bridgingParams = {
1715+ sbtc : {
1716+ amount : 100000 ,
1717+ stacksRecipient : 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7' ,
1718+ maxFee : 5000 ,
1719+ lockTime : 144 ,
1720+ } ,
1721+ } ;
1722+ const expectedBuildParams = {
1723+ type : 'bridging' ,
1724+ txFormat : 'psbt' ,
1725+ recipients : [ ] ,
1726+ bridgingParams,
1727+ changeAddressType : [ 'p2trMusig2' , 'p2wsh' , 'p2shP2wsh' , 'p2sh' , 'p2tr' ] ,
1728+ } ;
1729+
1730+ const scope = nock ( bgUrl )
1731+ . post ( `/api/v2/${ wallet . coin ( ) } /wallet/${ wallet . id ( ) } /tx/build` , expectedBuildParams )
1732+ . query ( { } )
1733+ . reply ( 200 , { } ) ;
1734+ const blockHeightStub = sinon . stub ( basecoin , 'getLatestBlockHeight' ) . resolves ( 100 ) ;
1735+ const postProcessStub = sinon . stub ( basecoin , 'postProcessPrebuild' ) . resolves ( { } ) ;
1736+ await wallet . prebuildTransaction ( {
1737+ type : 'bridging' ,
1738+ txFormat : 'psbt' ,
1739+ recipients : [ ] ,
1740+ bridgingParams,
1741+ } ) ;
1742+ postProcessStub . should . have . been . calledOnceWith ( {
1743+ blockHeight : 100 ,
1744+ wallet : wallet ,
1745+ buildParams : expectedBuildParams ,
1746+ } ) ;
1747+ scope . done ( ) ;
1748+ blockHeightStub . restore ( ) ;
1749+ postProcessStub . restore ( ) ;
1750+ } ) ;
1751+
17131752 it ( 'prebuild should call build but not getLatestBlockHeight for account coins' , async function ( ) {
17141753 [ 'txrp' , 'txlm' , 'teth' ] . forEach ( async function ( coin ) {
17151754 const accountcoin = bitgo . coin ( coin ) ;
@@ -2468,8 +2507,22 @@ describe('V2 Wallet:', function () {
24682507 multisigType : 'tss' ,
24692508 } ;
24702509
2510+ const btcWalletData = {
2511+ id : '5b34252f1bf349930e34020a11111111' ,
2512+ coin : 'tbtc' ,
2513+ keys : [
2514+ '598f606cd8fc24710d2ebad89dce86c2' ,
2515+ '598f606cc8e43aef09fcb785221d9dd2' ,
2516+ '5935d59cf660764331bafcade1855fd7' ,
2517+ ] ,
2518+ multisigType : 'tss' ,
2519+ coinSpecific : { } ,
2520+ type : 'hot' ,
2521+ } ;
2522+
24712523 const tssSolWallet = new Wallet ( bitgo , tsol , walletData ) ;
24722524 const tssAdaWallet = new Wallet ( bitgo , tada , adaWalletData ) ;
2525+ const tssBtcWallet = new Wallet ( bitgo , basecoin , btcWalletData ) ;
24732526
24742527 let tssEthWallet = new Wallet ( bitgo , bitgo . coin ( 'teth' ) , ethWalletData ) ;
24752528 const tssPolygonWallet = new Wallet ( bitgo , bitgo . coin ( 'tpolygon' ) , polygonWalletData ) ;
@@ -3536,6 +3589,35 @@ describe('V2 Wallet:', function () {
35363589 args [ 1 ] ! . should . equal ( 'full' ) ;
35373590 } ) ;
35383591
3592+ it ( 'should call prebuildTxWithIntent with the correct params for bridging on BTC wallet' , async function ( ) {
3593+ const bridgingParams = {
3594+ sbtc : {
3595+ amount : 100000 ,
3596+ stacksRecipient : 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7' ,
3597+ maxFee : 5000 ,
3598+ lockTime : 144 ,
3599+ } ,
3600+ } ;
3601+
3602+ const prebuildTxWithIntent = sandbox . stub ( ECDSAUtils . EcdsaUtils . prototype , 'prebuildTxWithIntent' ) ;
3603+ prebuildTxWithIntent . resolves ( txRequestFull ) ;
3604+
3605+ await tssBtcWallet . prebuildTransaction ( {
3606+ reqId,
3607+ type : 'bridging' ,
3608+ recipients : [ ] ,
3609+ bridgingParams,
3610+ txFormat : 'psbt' ,
3611+ } ) ;
3612+
3613+ sinon . assert . calledOnce ( prebuildTxWithIntent ) ;
3614+ const args = prebuildTxWithIntent . args [ 0 ] ;
3615+ args [ 0 ] ! . intentType . should . equal ( 'bridging' ) ;
3616+ args [ 0 ] ! . bridgingParams ! . should . deepEqual ( bridgingParams ) ;
3617+ args [ 0 ] ! . recipients ! . should . deepEqual ( [ ] ) ;
3618+ args [ 1 ] ! . should . equal ( 'full' ) ;
3619+ } ) ;
3620+
35393621 it ( 'should call prebuildTxWithIntent with the correct params for Export' , async function ( ) {
35403622 const recipients = [
35413623 {
@@ -3915,6 +3997,37 @@ describe('V2 Wallet:', function () {
39153997 intent . should . have . property ( 'recipients' , undefined ) ;
39163998 } ) ;
39173999
4000+ it ( 'populate intent should include bridgingParams only for bridging intent type on BTC' , async function ( ) {
4001+ const tbtc = bitgo . coin ( 'tbtc' ) ;
4002+ const mpcUtils = new ECDSAUtils . EcdsaUtils ( bitgo , tbtc ) ;
4003+ const bridgingParams = {
4004+ sbtc : {
4005+ amount : 100000 ,
4006+ stacksRecipient : 'SP2J6ZY48GV1EZ5V2V5RB9MP66SW86PYKKNRV9EJ7' ,
4007+ maxFee : 5000 ,
4008+ lockTime : 144 ,
4009+ } ,
4010+ } ;
4011+
4012+ // bridgingParams should be included when intentType is 'bridging'
4013+ const bridgingIntent = mpcUtils . populateIntent ( tbtc , {
4014+ reqId,
4015+ intentType : 'bridging' ,
4016+ recipients : [ { address : 'tb1qexample' , amount : '100000' } ] ,
4017+ bridgingParams,
4018+ } ) ;
4019+ bridgingIntent . bridgingParams ! . should . deepEqual ( bridgingParams ) ;
4020+
4021+ // bridgingParams should NOT be included for other intent types
4022+ const paymentIntent = mpcUtils . populateIntent ( tbtc , {
4023+ reqId,
4024+ intentType : 'payment' ,
4025+ recipients : [ { address : 'tb1qexample' , amount : '100000' } ] ,
4026+ bridgingParams,
4027+ } ) ;
4028+ paymentIntent . should . not . have . property ( 'bridgingParams' ) ;
4029+ } ) ;
4030+
39184031 it ( 'populate intent should return valid export intent for EVM cross-chain' , async function ( ) {
39194032 const mpcUtils = new ECDSAUtils . EcdsaUtils ( bitgo , bitgo . coin ( 'hteth' ) ) ;
39204033 const feeOptions = {
0 commit comments