Skip to content
Merged
6 changes: 3 additions & 3 deletions modules/abstract-utxo/src/abstractUtxoCoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ export function isWalletOutput(output: Output): output is FixedScriptWalletOutpu
);
}

export interface TransactionExplanation extends BaseTransactionExplanation<string, string> {
locktime: number;
export interface TransactionExplanation<TFee = string> extends BaseTransactionExplanation<TFee, string> {
locktime?: number;
/** NOTE: this actually only captures external outputs */
outputs: Output[];
changeOutputs: Output[];
Expand Down Expand Up @@ -872,7 +872,7 @@ export abstract class AbstractUtxoCoin extends BaseCoin {
*/
async explainTransaction<TNumber extends number | bigint = number>(
params: ExplainTransactionOptions<TNumber>
): Promise<TransactionExplanation> {
): Promise<TransactionExplanation<string | undefined>> {
return explainTx(this.decodeTransactionFromPrebuild(params), params, this.network);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/abstract-utxo/src/impl/doge/doge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class Doge extends AbstractUtxoCoin {

async explainTransaction<TNumber extends number | bigint = bigint>(
params: ExplainTransactionOptions<TNumber> | (ExplainTransactionOptions<TNumber> & { txInfo: TransactionInfoJSON })
): Promise<TransactionExplanation> {
): Promise<TransactionExplanation<string | undefined>> {
return super.explainTransaction({
...params,
txInfo: params.txInfo ? parseTransactionInfo(params.txInfo as TransactionInfoJSON) : undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export interface ExplanationOutput {
amount: string | number;
}

export interface TransactionExplanation {
export interface TransactionExplanation<TFee> {
outputs: ExplanationOutput[];
changeOutputs: ExplanationOutput[];
fee: {
/* network fee */
fee: string | number;
fee: TFee;
payGoFeeString: string | number | undefined;
payGoFeeAddress: string | undefined;
};
}

export function getTransactionExplanation(coin: string, tx: unknown): TransactionExplanation {
export function getTransactionExplanation(coin: string, tx: unknown): TransactionExplanation<string> {
if (!OfflineVaultSignable.is(tx)) {
throw new Error('not a signable transaction');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function getHalfSignedPsbt(
export function getTransactionExplanationFromPsbt(
tx: DescriptorTransaction,
network: utxolib.Network
): TransactionExplanation {
): TransactionExplanation<string> {
const psbt = utxolib.bitgo.createPsbtDecode(tx.coinSpecific.txHex, network);
const descriptorMap = getDescriptorsFromDescriptorTransaction(tx);
const { outputs, changeOutputs, fee } = explainPsbt(psbt, descriptorMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function getInputSignatures(psbt: utxolib.bitgo.UtxoPsbt): number[] {
export function explainPsbt(
psbt: utxolib.bitgo.UtxoPsbt,
descriptors: coreDescriptors.DescriptorMap
): TransactionExplanation {
): TransactionExplanation<string> {
const parsedTransaction = coreDescriptors.parse(psbt, descriptors, psbt.network);
const { inputs, outputs } = parsedTransaction;
const externalOutputs = outputs.filter((o) => o.scriptId === undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function explainTx<TNumber extends number | bigint>(
changeInfo?: fixedScript.ChangeAddressInfo[];
},
network: utxolib.Network
): TransactionExplanation {
): TransactionExplanation<string | undefined> {
if (params.wallet && isDescriptorWallet(params.wallet)) {
if (tx instanceof utxolib.bitgo.UtxoPsbt) {
if (!params.pubs || !isTriple(params.pubs)) {
Expand Down
Loading