Skip to content

Commit 4548dfc

Browse files
OttoAllmendingerllm-git
andcommitted
feat(abstract-utxo): rename signPsbt to getMusig2Nonces
Rename method to better reflect its actual functionality as a getter for MuSig2 nonces rather than a signing operation. Keep the old method as deprecated to maintain backward compatibility. Issue: BTC-2806 Co-authored-by: llm-git <[email protected]>
1 parent c229e63 commit 4548dfc

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

modules/abstract-utxo/src/abstractUtxoCoin.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,22 +712,32 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
712712
* @param psbtHex all MuSig2 inputs should contain user MuSig2 nonce
713713
* @param walletId
714714
*/
715-
async signPsbt(psbtHex: string, walletId: string): Promise<SignPsbtResponse> {
715+
async getMusig2Nonces(psbtHex: string, walletId: string): Promise<SignPsbtResponse> {
716716
const params: SignPsbtRequest = { psbt: psbtHex };
717717
return await this.bitgo
718718
.post(this.url('/wallet/' + walletId + '/tx/signpsbt'))
719719
.send(params)
720720
.result();
721721
}
722722

723+
/**
724+
* @deprecated Use getMusig2Nonces instead
725+
* @returns input psbt added with deterministic MuSig2 nonce for bitgo key for each MuSig2 inputs.
726+
* @param psbtHex all MuSig2 inputs should contain user MuSig2 nonce
727+
* @param walletId
728+
*/
729+
async signPsbt(psbtHex: string, walletId: string): Promise<SignPsbtResponse> {
730+
return this.getMusig2Nonces(psbtHex, walletId);
731+
}
732+
723733
/**
724734
* @returns input psbt added with deterministic MuSig2 nonce for bitgo key for each MuSig2 inputs from OVC.
725735
* @param ovcJson JSON object provided by OVC with fields psbtHex and walletId
726736
*/
727737
async signPsbtFromOVC(ovcJson: Record<string, unknown>): Promise<Record<string, unknown>> {
728738
assert(ovcJson['psbtHex'], 'ovcJson must contain psbtHex');
729739
assert(ovcJson['walletId'], 'ovcJson must contain walletId');
730-
const psbt = (await this.signPsbt(ovcJson['psbtHex'] as string, ovcJson['walletId'] as string)).psbt;
740+
const psbt = (await this.getMusig2Nonces(ovcJson['psbtHex'] as string, ovcJson['walletId'] as string)).psbt;
731741
assert(psbt, 'psbt not found');
732742
return _.extend(ovcJson, { txHex: psbt });
733743
}

modules/abstract-utxo/src/transaction/fixedScript/signTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function signTransaction<TNumber extends number | bigint>(
5959
return { txHex: tx.toHex() };
6060
case 'cosignerNonce':
6161
assert(params.walletId, 'walletId is required for MuSig2 bitgo nonce');
62-
return { txHex: (await coin.signPsbt(tx.toHex(), params.walletId)).psbt };
62+
return { txHex: (await coin.getMusig2Nonces(tx.toHex(), params.walletId)).psbt };
6363
case 'signerSignature':
6464
const txId = tx.getUnsignedTx().getId();
6565
const psbt = PSBT_CACHE.get(txId);
@@ -76,7 +76,7 @@ export async function signTransaction<TNumber extends number | bigint>(
7676
assert(params.walletId, 'walletId is required for MuSig2 bitgo nonce');
7777
assert(signerKeychain);
7878
tx.setAllInputsMusig2NonceHD(signerKeychain);
79-
const response = await coin.signPsbt(tx.toHex(), params.walletId);
79+
const response = await coin.getMusig2Nonces(tx.toHex(), params.walletId);
8080
tx.combine(bitgo.createPsbtFromHex(response.psbt, coin.network));
8181
break;
8282
}

0 commit comments

Comments
 (0)