@@ -18,11 +18,11 @@ import {
1818 isStandardUnlockableUtxo ,
1919 StandardUnlockableUtxo ,
2020 VmResourceUsage ,
21- isContractUnlocker ,
22- BchChangeOutputOptions ,
23- TokenChangeOutputOptions ,
24- isPlaceholderUnlocker ,
25- } from './interfaces.js' ;
21+ isContractUnlocker ,
22+ BchChangeOutputOptions ,
23+ TokenChangeOutputOptions ,
24+ isPlaceholderUnlocker ,
25+ } from './interfaces.js' ;
2626import { NetworkProvider } from './network/index.js' ;
2727import {
2828 calculateDust ,
@@ -37,15 +37,15 @@ import {
3737import { FailedTransactionError } from './Errors.js' ;
3838import { DebugResults } from './debugging.js' ;
3939import { debugLibauthTemplate , getLibauthTemplate , getBitauthUri } from './libauth-template/LibauthTemplate.js' ;
40- import {
41- getWcContractInfo ,
42- WcSourceOutput ,
43- WcTransactionOptions ,
44- WizardConnectInputPath ,
45- WizardConnectTransactionObject ,
46- } from './walletconnect-utils.js' ;
40+ import {
41+ getWcContractInfo ,
42+ WalletConnectSourceOutput ,
43+ WalletConnectTransactionOptions ,
44+ WizardConnectInputPath ,
45+ WizardConnectTransactionObject ,
46+ } from './walletconnect-utils.js' ;
4747import semver from 'semver' ;
48- import { WcTransactionObject } from './walletconnect-utils.js' ;
48+ import { WalletConnectTransactionObject } from './walletconnect-utils.js' ;
4949
5050/**
5151 * Options accepted by the `TransactionBuilder` constructor.
@@ -558,6 +558,13 @@ export class TransactionBuilder {
558558 throw new Error ( 'Could not retrieve transaction details for over 10 minutes' ) ;
559559 }
560560
561+ /**
562+ * @deprecated Use `generateWalletConnectTransactionObject` instead.
563+ */
564+ generateWcTransactionObject ( options ?: WalletConnectTransactionOptions ) : WalletConnectTransactionObject {
565+ return this . generateWalletConnectTransactionObject ( options ) ;
566+ }
567+
561568 /**
562569 * Build the transaction and format it as a BCH WalletConnect transaction object suitable for
563570 * signing and broadcasting via a BCH WalletConnect-compatible Bitcoin Cash wallet.
@@ -568,52 +575,52 @@ export class TransactionBuilder {
568575 * @returns A WalletConnect transaction object ready to be sent to a WalletConnect wallet.
569576 * @throws If the transaction cannot be built (fee exceeds limit or fungible tokens burned).
570577 */
571- generateWcTransactionObject ( options ?: WcTransactionOptions ) : WcTransactionObject {
572- const encodedTransaction = this . build ( ) ;
573- const transaction = decodeTransactionUnsafe ( hexToBin ( encodedTransaction ) ) ;
578+ generateWalletConnectTransactionObject ( options ?: WalletConnectTransactionOptions ) : WalletConnectTransactionObject {
579+ const encodedTransaction = this . build ( ) ;
580+ const transaction = decodeTransactionUnsafe ( hexToBin ( encodedTransaction ) ) ;
574581
575582 const libauthSourceOutputs = generateLibauthSourceOutputs ( this . inputs ) ;
576- const sourceOutputs : WcSourceOutput [ ] = libauthSourceOutputs . map ( ( sourceOutput , index ) => {
583+ const sourceOutputs : WalletConnectSourceOutput [ ] = libauthSourceOutputs . map ( ( sourceOutput , index ) => {
577584 return {
578585 ...sourceOutput ,
579586 ...transaction . inputs [ index ] ,
580587 ...getWcContractInfo ( this . inputs [ index ] ) ,
581588 } ;
582- } ) ;
583- return { ...options , transaction, sourceOutputs } ;
584- }
585-
586- /**
587- * Build the transaction and format it as a WizardConnect transaction request.
588- *
589- * WizardConnect uses the standard BCH WalletConnect transaction object plus HD path metadata for
590- * each placeholder P2PKH input that the wallet must sign.
591- *
592- * @param options - Optional WalletConnect options such as `broadcast` and `userPrompt`.
593- * @returns A WizardConnect transaction object ready to be sent to a WizardConnect wallet.
594- * @throws If the transaction cannot be built, or if a placeholder input is missing HD path metadata.
595- */
596- generateWizardConnectTransactionObject ( options ?: WcTransactionOptions ) : WizardConnectTransactionObject {
597- const transaction = this . generateWcTransactionObject ( options ) ;
598- const inputPaths = this . generateWizardConnectInputPaths ( ) ;
599-
600- return { transaction, inputPaths } ;
601- }
602-
603- private generateWizardConnectInputPaths ( ) : WizardConnectInputPath [ ] {
604- const inputPaths : WizardConnectInputPath [ ] = [ ] ;
605-
606- this . inputs . forEach ( ( input , inputIndex ) => {
607- if ( ! isPlaceholderUnlocker ( input . unlocker ) ) return ;
608-
609- const hdPath = input . unlocker . hdPath ;
610- if ( ! hdPath ) {
611- throw new Error ( `Placeholder P2PKH input ${ inputIndex } is missing WizardConnect HD path metadata` ) ;
612- }
613-
614- inputPaths . push ( [ inputIndex , hdPath . name , hdPath . addressIndex ] ) ;
615- } ) ;
616-
617- return inputPaths ;
618- }
619- }
589+ } ) ;
590+ return { ...options , transaction, sourceOutputs } ;
591+ }
592+
593+ /**
594+ * Build the transaction and format it as a WizardConnect transaction request.
595+ *
596+ * WizardConnect uses the standard BCH WalletConnect transaction object plus HD path metadata for
597+ * each placeholder P2PKH input that the wallet must sign.
598+ *
599+ * @param options - Optional WalletConnect options such as `broadcast` and `userPrompt`.
600+ * @returns A WizardConnect transaction object ready to be sent to a WizardConnect wallet.
601+ * @throws If the transaction cannot be built, or if a placeholder input is missing HD path metadata.
602+ */
603+ generateWizardConnectTransactionObject ( options ?: WalletConnectTransactionOptions ) : WizardConnectTransactionObject {
604+ const transaction = this . generateWalletConnectTransactionObject ( options ) ;
605+ const inputPaths = this . generateWizardConnectInputPaths ( ) ;
606+
607+ return { transaction, inputPaths } ;
608+ }
609+
610+ private generateWizardConnectInputPaths ( ) : WizardConnectInputPath [ ] {
611+ const inputPaths : WizardConnectInputPath [ ] = [ ] ;
612+
613+ this . inputs . forEach ( ( input , inputIndex ) => {
614+ if ( ! isPlaceholderUnlocker ( input . unlocker ) ) return ;
615+
616+ const hdPath = input . unlocker . hdPath ;
617+ if ( ! hdPath ) {
618+ throw new Error ( `Placeholder P2PKH input ${ inputIndex } is missing WizardConnect HD path metadata` ) ;
619+ }
620+
621+ inputPaths . push ( [ inputIndex , hdPath . name , hdPath . addressIndex ] ) ;
622+ } ) ;
623+
624+ return inputPaths ;
625+ }
626+ }
0 commit comments