From 4c242b5ab02f7464c1682e9f34ee699874b86229 Mon Sep 17 00:00:00 2001 From: Micah Kendall Date: Mon, 15 Apr 2024 03:07:58 +1000 Subject: [PATCH] native script extra signers --- packages/translucent-tx/tx.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/translucent-tx/tx.ts b/packages/translucent-tx/tx.ts index dece14f..990c763 100644 --- a/packages/translucent-tx/tx.ts +++ b/packages/translucent-tx/tx.ts @@ -135,6 +135,7 @@ export class TxBuilder { private fee: bigint = 0n // The fee for the transaction. private overEstimateSteps = 1.2 // A multiplier to overestimate the execution steps for Plutus scripts. private overEstimateMem = 1.05 // A multiplier to overestimate the memory usage for Plutus scripts. + private additionalSigners = 0; /** * Constructs a new instance of the TxBuilder class. @@ -155,6 +156,16 @@ export class TxBuilder { this.changeAddress = address } + /** + * The additional signers field is used to add additional signing counts for fee calculation. + * These will be included in the signing phase at a later stage. + * This is needed due to native scripts signees being non-deterministic. + * @param {number} amount - The amount of additional signers + */ + addAdditionalSigners(amount: number){ + this.additionalSigners += amount + } + /** * Adds a reference input to the transaction. Reference inputs are used to refer to outputs from previous transactions * without spending them, allowing scripts to read their data. This can be useful for various contract logic, such as @@ -523,6 +534,9 @@ export class TxBuilder { for (const val of this.requiredWitnesses.values()) { requiredWitnesses.push(VkeyWitness.fromCore([Ed25519PublicKeyHex("0".repeat(64)), Ed25519SignatureHex('0'.repeat(128))])) } + for (let i = 0; i < this.additionalSigners; i++){ + requiredWitnesses.push(VkeyWitness.fromCore([Ed25519PublicKeyHex("0".repeat(64)), Ed25519SignatureHex('0'.repeat(128))])) + } vkeyWitnesses.setValues(requiredWitnesses) tw.setVkeys(vkeyWitnesses) tw.setRedeemers(this.redeemers)