@@ -5,7 +5,7 @@ import * as utxocore from '@bitgo/utxo-core';
5
5
6
6
import { Output , TransactionExplanation , FixedScriptWalletOutput } from '../../abstractUtxoCoin' ;
7
7
import { toExtendedAddressFormat } from '../recipient' ;
8
- import { Networks } from '../../../../statics/src/networks ' ;
8
+ import { getPayGoVerificationPubkey } from '../getPayGoVerificationPubkey ' ;
9
9
10
10
export type ChangeAddressInfo = { address : string ; chain : number ; index : number } ;
11
11
@@ -198,31 +198,33 @@ export function explainPsbt<TNumber extends number | bigint, Tx extends bitgo.Ut
198
198
* Extract PayGo address proof information from the PSBT if present
199
199
* @returns Information about the PayGo proof, including the output index and address
200
200
*/
201
- function getPayGoVerificationInfo ( ) :
202
- | { outputIndex : number | undefined ; verificationPubkey : string | undefined }
203
- | undefined {
201
+ function getPayGoVerificationInfo ( ) : { outputIndex : number ; verificationPubkey : string } | undefined {
204
202
let outputIndex : number | undefined = undefined ;
205
203
let address : string | undefined = undefined ;
206
- const verificationPubkey = Networks . test . bitcoin . paygoAddressAttestationPubkey ;
207
204
// Check if this PSBT has any PayGo address proofs
208
205
if ( ! utxocore . paygo . psbtOutputIncludesPaygoAddressProof ( psbt ) ) {
209
206
return undefined ;
210
207
}
211
208
209
+ // This pulls the pubkey depending on given network
210
+ const verificationPubkey = getPayGoVerificationPubkey ( network ) ;
211
+
212
212
// find which output index that contains the PayGo proof
213
213
outputIndex = utxocore . paygo . getPayGoAddressProofOutputIndex ( psbt ) ;
214
- if ( outputIndex !== undefined ) {
215
- const output = txOutputs [ outputIndex ] ;
216
- address = utxolib . address . fromOutputScript ( output . script , network ) ;
217
- if ( ! address ) {
218
- return undefined ;
219
- }
214
+ if ( ! outputIndex || ! verificationPubkey ) {
215
+ return undefined ;
220
216
}
217
+ const output = txOutputs [ outputIndex ] ;
218
+ address = utxolib . address . fromOutputScript ( output . script , network ) ;
219
+ if ( ! address ) {
220
+ return undefined ;
221
+ }
222
+
221
223
return { outputIndex, verificationPubkey } ;
222
224
}
223
225
224
226
const payGoVerificationInfo = getPayGoVerificationInfo ( ) ;
225
- if ( payGoVerificationInfo && payGoVerificationInfo . outputIndex && payGoVerificationInfo . verificationPubkey ) {
227
+ if ( payGoVerificationInfo ) {
226
228
utxocore . paygo . verifyPayGoAddressProof (
227
229
psbt ,
228
230
payGoVerificationInfo . outputIndex ,
0 commit comments