Skip to content

Commit

Permalink
native script extra signers
Browse files Browse the repository at this point in the history
  • Loading branch information
micahkendall committed Apr 14, 2024
1 parent ce38283 commit 4c242b5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/translucent-tx/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4c242b5

Please sign in to comment.