@@ -5,7 +5,7 @@ import * as _ from 'lodash';
55import * as utxolib from '@bitgo/utxo-lib' ;
66import nock = require( 'nock' ) ;
77import { BIP32Interface , bitgo , testutil } from '@bitgo/utxo-lib' ;
8- import { address as wasmAddress } from '@bitgo/wasm-utxo' ;
8+ import { address as wasmAddress , fixedScriptWallet } from '@bitgo/wasm-utxo' ;
99import {
1010 common ,
1111 FullySignedTransaction ,
@@ -108,6 +108,7 @@ function run<TNumber extends number | bigint = number>(
108108 prv : signer . toBase58 ( ) ,
109109 pubs : walletKeys . triple . map ( ( k ) => k . neutered ( ) . toBase58 ( ) ) ,
110110 cosignerPub : cosigner . neutered ( ) . toBase58 ( ) ,
111+ extractTransaction : false ,
111112 } as WalletSignTransactionOptions ;
112113 }
113114
@@ -223,7 +224,7 @@ function run<TNumber extends number | bigint = number>(
223224
224225 function toTransactionStagesObj ( stages : TransactionStages ) : TransactionObjStages {
225226 return _ . mapValues ( stages , ( v ) =>
226- v === undefined || v instanceof utxolib . bitgo . UtxoPsbt
227+ v === undefined || v instanceof utxolib . bitgo . UtxoPsbt || v instanceof fixedScriptWallet . BitGoPsbt
227228 ? undefined
228229 : v instanceof utxolib . bitgo . UtxoTransaction
229230 ? transactionToObj < TNumber > ( v )
@@ -266,14 +267,11 @@ function run<TNumber extends number | bigint = number>(
266267 signedBy : BIP32Interface [ ] ,
267268 sign : 'halfsigned' | 'fullsigned'
268269 ) {
269- if ( txFormat === 'psbt' && sign === 'halfsigned' ) {
270+ if ( txFormat === 'psbt' ) {
270271 testPsbtValidSignatures ( tx , signedBy ) ;
271272 return ;
272273 }
273- const unspents =
274- txFormat === 'psbt'
275- ? getUnspentsForPsbt ( ) . map ( ( u ) => ( { ...u , value : bitgo . toTNumber ( u . value , amountType ) as TNumber } ) )
276- : getUnspents ( ) ;
274+ const unspents = getUnspents ( ) ;
277275 const prevOutputs = unspents . map (
278276 ( u ) : utxolib . TxOutput < TNumber > => ( {
279277 script : Buffer . from ( wasmAddress . toOutputScriptWithCoin ( u . address , coin . name ) ) ,
@@ -398,6 +396,8 @@ function run<TNumber extends number | bigint = number>(
398396 const txHex =
399397 stageTx instanceof utxolib . bitgo . UtxoPsbt || stageTx instanceof utxolib . bitgo . UtxoTransaction
400398 ? stageTx . toBuffer ( ) . toString ( 'hex' )
399+ : stageTx instanceof fixedScriptWallet . BitGoPsbt
400+ ? Buffer . from ( stageTx . serialize ( ) ) . toString ( 'hex' )
401401 : stageTx . txHex ;
402402
403403 const pubs = walletKeys . triple . map ( ( k ) => k . neutered ( ) . toBase58 ( ) ) as Triple < string > ;
@@ -415,9 +415,7 @@ function run<TNumber extends number | bigint = number>(
415415}
416416
417417function runTestForCoin ( coin : AbstractUtxoCoin ) {
418- ( [ 'legacy' , 'psbt' ] as const ) . forEach ( ( txFormat ) => {
419- run ( coin , getScriptTypes ( coin , txFormat ) , txFormat , { decodeWith : 'wasm-utxo' } ) ;
420- } ) ;
418+ run ( coin , getScriptTypes ( coin , 'psbt' ) , 'psbt' , { decodeWith : 'wasm-utxo' } ) ;
421419}
422420
423421describe ( 'Transaction Suite' , function ( ) {
0 commit comments