@kaspacom/kcc20-tx-builder 0.8.0-fee.3 → 0.8.0-fee.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/RELEASING.md +3 -2
- package/dist/cjs/engine.js +12 -1
- package/dist/cjs/engine.js.map +1 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +12 -1
- package/dist/engine.js.map +1 -1
- package/docs/COMPATIBILITY.json +1 -1
- package/docs/escrow-fees.md +3 -1
- package/package.json +1 -1
- package/src/engine.ts +15 -1
package/docs/COMPATIBILITY.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": "kcc20-example-compatibility/v1",
|
|
3
|
-
"packageVersion": "0.8.0-fee.
|
|
3
|
+
"packageVersion": "0.8.0-fee.4",
|
|
4
4
|
"contractsRepository": "https://github.com/KASPACOM/kaspa-covenants",
|
|
5
5
|
"contractsCommit": "5deb1769e69142595576ef7c573af9f433a48a3c",
|
|
6
6
|
"compiler": {
|
package/docs/escrow-fees.md
CHANGED
|
@@ -10,7 +10,8 @@ disabled, and this change does not publish a package.
|
|
|
10
10
|
genesis output and a separate wallet change output. The caller supplies the
|
|
11
11
|
native token ID and account principal in sompi. The connected wallet's Schnorr
|
|
12
12
|
public key controls the account. The builder pins the escrow artifact, checks
|
|
13
|
-
|
|
13
|
+
that this key matches the funding wallet's Schnorr address, computes the account
|
|
14
|
+
covenant ID, and checks the signed transaction's
|
|
14
15
|
fee and mass before returning the PSKT. The wallet signs the funding input.
|
|
15
16
|
|
|
16
17
|
The creation result includes `metadata.accountGenesisHint`. Save it with the
|
|
@@ -24,6 +25,7 @@ lineage, outpoint and principal against the pinned artifact. The wallet signs
|
|
|
24
25
|
the account input and a separate funding input. The bound output keeps the
|
|
25
26
|
same account ID and exact principal. Binding is a one-time operation; later
|
|
26
27
|
authority changes use the contract's rotation path.
|
|
28
|
+
The account outpoint cannot also serve as the funding input.
|
|
27
29
|
|
|
28
30
|
These operations prepare wallet-signable transactions. They do not broadcast
|
|
29
31
|
or establish funded TN10 execution. Account creation and binding are only the
|
package/package.json
CHANGED
package/src/engine.ts
CHANGED
|
@@ -617,6 +617,7 @@ export function createKcc20PsktBuilderEngine(
|
|
|
617
617
|
const principalSompi = parseU64(params.principalSompi, "fee account principal");
|
|
618
618
|
const network = request.network || env.KASPA_NETWORK || "testnet-10";
|
|
619
619
|
const walletAddress = requireKaspaAddress(request.owner?.walletAddress);
|
|
620
|
+
assertFeeAccountSchnorrWalletOwner(walletAddress, owner);
|
|
620
621
|
const priorityFee = parseU64(
|
|
621
622
|
env.KCC20_FEE_ACCOUNT_PRIORITY_FEE_SOMPI || DEFAULT_PRIORITY_FEE.toString(),
|
|
622
623
|
"priorityFee",
|
|
@@ -748,6 +749,7 @@ export function createKcc20PsktBuilderEngine(
|
|
|
748
749
|
}
|
|
749
750
|
const network = request.network || env.KASPA_NETWORK || "testnet-10";
|
|
750
751
|
const walletAddress = requireKaspaAddress(request.owner?.walletAddress);
|
|
752
|
+
assertFeeAccountSchnorrWalletOwner(walletAddress, owner);
|
|
751
753
|
const accountAddress = requireKaspaAddress(indexed.address);
|
|
752
754
|
const priorityFee = parseU64(
|
|
753
755
|
env.KCC20_FEE_ACCOUNT_PRIORITY_FEE_SOMPI || DEFAULT_PRIORITY_FEE.toString(),
|
|
@@ -801,7 +803,7 @@ export function createKcc20PsktBuilderEngine(
|
|
|
801
803
|
const fundingEntry = selectFundingEntry(
|
|
802
804
|
walletUtxos.entries,
|
|
803
805
|
priorityFee + 10_000n,
|
|
804
|
-
[],
|
|
806
|
+
[accountEntry.outpoint],
|
|
805
807
|
params.fundingOutpoint,
|
|
806
808
|
);
|
|
807
809
|
const fundingAmount = utxoAmountSompi(fundingEntry);
|
|
@@ -832,6 +834,7 @@ export function createKcc20PsktBuilderEngine(
|
|
|
832
834
|
});
|
|
833
835
|
setVersionOneInputMassFields(unsignedTx, computeBudget);
|
|
834
836
|
unsignedTx.inputs[1].computeBudget = 30;
|
|
837
|
+
assertUniqueTransactionInputOutpoints(unsignedTx, "fee account binding");
|
|
835
838
|
const scripts = [{
|
|
836
839
|
inputIndex: 0,
|
|
837
840
|
scriptHex: bytesToHex(plan.currentRedeemScript),
|
|
@@ -13745,6 +13748,17 @@ export function createKcc20PsktBuilderEngine(
|
|
|
13745
13748
|
return address;
|
|
13746
13749
|
}
|
|
13747
13750
|
|
|
13751
|
+
function assertFeeAccountSchnorrWalletOwner(walletAddress, owner) {
|
|
13752
|
+
const script = String(kaspaWasm.payToAddressScript(walletAddress).script)
|
|
13753
|
+
.toLowerCase();
|
|
13754
|
+
const publicKey = /^20([0-9a-f]{64})ac$/.exec(script)?.[1];
|
|
13755
|
+
if (!publicKey || publicKey !== owner) {
|
|
13756
|
+
throw new Error(
|
|
13757
|
+
"fee account owner must match the connected Schnorr wallet address",
|
|
13758
|
+
);
|
|
13759
|
+
}
|
|
13760
|
+
}
|
|
13761
|
+
|
|
13748
13762
|
return {
|
|
13749
13763
|
build: buildInProcessPskt,
|
|
13750
13764
|
buildInProcessPskt,
|