77 getBabylonParamByVersion ,
88 StakerInfo ,
99 StakingInputs ,
10+ StakingParams ,
1011 VersionedStakingParams ,
1112} from '@bitgo/babylonlabs-io-btc-staking-ts' ;
1213export { getBabylonParamByVersion , getBabylonParamByBtcHeight } from '@bitgo/babylonlabs-io-btc-staking-ts' ;
@@ -94,13 +95,16 @@ export const testnetFinalityProvider0 = Buffer.from(
9495 'hex'
9596) ;
9697
98+ type DescriptorStakingParams = Pick <
99+ StakingParams ,
100+ 'covenantNoCoordPks' | 'covenantQuorum' | 'minStakingTimeBlocks' | 'unbondingTime'
101+ > ;
102+
97103export function getDescriptorBuilderForParams (
98104 userKey : utxolib . BIP32Interface | utxolib . ECPairInterface | Buffer ,
99105 finalityProviderKeys : Buffer [ ] ,
100- params : Pick <
101- VersionedStakingParams ,
102- 'covenantNoCoordPks' | 'covenantQuorum' | 'minStakingTimeBlocks' | 'unbondingTime'
103- >
106+ stakingTimelock : number ,
107+ params : DescriptorStakingParams
104108) : BabylonDescriptorBuilder {
105109 if ( ! Buffer . isBuffer ( userKey ) ) {
106110 userKey = userKey . publicKey ;
@@ -110,32 +114,32 @@ export function getDescriptorBuilderForParams(
110114 finalityProviderKeys ,
111115 params . covenantNoCoordPks . map ( ( pk ) => Buffer . from ( pk , 'hex' ) ) ,
112116 params . covenantQuorum ,
113- params . minStakingTimeBlocks ,
117+ stakingTimelock ,
114118 params . unbondingTime
115119 ) ;
116120}
117121
118122export function getDescriptorProviderForStakingParams (
119- stakerBtcInfo : StakerInfo ,
123+ stakerBtcInfo : Pick < StakerInfo , 'publicKeyNoCoordHex' > ,
120124 stakingInput : StakingInputs ,
121- stakingParams : VersionedStakingParams
125+ stakingParams : DescriptorStakingParams
122126) : BabylonDescriptorBuilder {
123127 const userKey = Buffer . from ( stakerBtcInfo . publicKeyNoCoordHex , 'hex' ) ;
124128 const finalityProviderKey = Buffer . from ( stakingInput . finalityProviderPkNoCoordHex , 'hex' ) ;
125- return getDescriptorBuilderForParams ( userKey , [ finalityProviderKey ] , stakingParams ) ;
129+ return getDescriptorBuilderForParams ( userKey , [ finalityProviderKey ] , stakingInput . stakingTimelock , stakingParams ) ;
126130}
127131
128132export function getTestnetDescriptorBuilder (
129133 userKey : utxolib . BIP32Interface | utxolib . ECPairInterface | Buffer ,
130134 {
131135 finalityProviderKeys = [ testnetFinalityProvider0 ] ,
136+ params = getBabylonParamByVersion ( 5 , getStakingParams ( 'testnet' ) ) ,
137+ stakingTimelock = params . minStakingTimeBlocks ,
132138 } : {
133139 finalityProviderKeys ?: Buffer [ ] ;
140+ params ?: StakingParams ;
141+ stakingTimelock ?: number ;
134142 } = { }
135143) : BabylonDescriptorBuilder {
136- return getDescriptorBuilderForParams (
137- userKey ,
138- finalityProviderKeys ,
139- getBabylonParamByVersion ( 5 , getStakingParams ( 'testnet' ) )
140- ) ;
144+ return getDescriptorBuilderForParams ( userKey , finalityProviderKeys , stakingTimelock , params ) ;
141145}
0 commit comments