Skip to content

Commit 3041bc3

Browse files
authored
Merge pull request #6758 from BitGo/BTC-2402.fix-pop
fix(utxo-staking): improve proof of possession validation and signature
2 parents 2514705 + 46cd679 commit 3041bc3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

modules/utxo-staking/src/babylon/stakingManager.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class BitGoStakingManager extends vendor.BabylonBtcStakingManager {
3939
stakerBtcAddress: string,
4040
sigType: BTCSigType
4141
): Promise<ProofOfPossessionBTC> {
42+
if (!bech32Address.startsWith('bbn1')) {
43+
throw new Error('invalid bech32 babylon address, must start with bbn1');
44+
}
4245
const signedBabylonAddress = await this.btcProvider.signMessage(
4346
bech32Address,
4447
sigType === BTCSigType.BIP322 ? 'bip322-simple' : 'ecdsa'
@@ -65,11 +68,16 @@ class BitGoStakingManager extends vendor.BabylonBtcStakingManager {
6568

6669
/**
6770
* Creates a proof of possession for the staker based on ECDSA signature.
71+
* @param channel - The channel for which the proof of possession is created.
6872
* @param bech32Address - The staker's bech32 address on the babylon network.
6973
* @param stakerBtcAddress
7074
* @returns The proof of possession.
7175
*/
72-
async createProofOfPossession(bech32Address: string, stakerBtcAddress: string): Promise<ProofOfPossessionBTC> {
76+
override async createProofOfPossession(
77+
channel: 'delegation:create' | 'delegation:register',
78+
bech32Address: string,
79+
stakerBtcAddress: string
80+
): Promise<ProofOfPossessionBTC> {
7381
// force the ECDSA signature type
7482
return this.createProofOfPossessionWithSigType(bech32Address, stakerBtcAddress, BTCSigType.ECDSA);
7583
}

0 commit comments

Comments
 (0)