@hazbase/simplicity 0.1.1 → 0.2.0
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/README.md +139 -1534
- package/dist/cli.js +1107 -1
- package/dist/client/SimplicityClient.d.ts +30 -3
- package/dist/client/SimplicityClient.js +28 -0
- package/dist/core/lineage.d.ts +18 -0
- package/dist/core/lineage.js +30 -0
- package/dist/core/reporting.d.ts +22 -0
- package/dist/core/reporting.js +40 -0
- package/dist/core/schnorr.d.ts +3 -3
- package/dist/core/schnorr.js +19 -7
- package/dist/core/types.d.ts +251 -5
- package/dist/docs/definitions/fund-capital-call-refund-only.simf +36 -2
- package/dist/docs/definitions/receivable-definition.json +9 -0
- package/dist/docs/definitions/receivable-funding-claim.json +13 -0
- package/dist/docs/definitions/receivable-funding-claim.simf +58 -0
- package/dist/docs/definitions/receivable-repayment-claim.json +13 -0
- package/dist/docs/definitions/receivable-repayment-claim.simf +59 -0
- package/dist/docs/definitions/receivable-state-funded.json +20 -0
- package/dist/docs/definitions/receivable-state-originated.json +19 -0
- package/dist/docs/definitions/receivable-state-repaid.json +20 -0
- package/dist/domain/bond.d.ts +82 -15
- package/dist/domain/bond.js +159 -10
- package/dist/domain/bondValidation.d.ts +31 -1
- package/dist/domain/bondValidation.js +73 -9
- package/dist/domain/fund.d.ts +451 -68
- package/dist/domain/fund.js +460 -88
- package/dist/domain/fundValidation.d.ts +33 -3
- package/dist/domain/fundValidation.js +137 -5
- package/dist/domain/policies.d.ts +13 -0
- package/dist/domain/policies.js +50 -30
- package/dist/domain/receivable.d.ts +824 -0
- package/dist/domain/receivable.js +1375 -0
- package/dist/domain/receivableValidation.d.ts +147 -0
- package/dist/domain/receivableValidation.js +831 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +55 -3
- package/package.json +6 -1
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { evaluateOutputBindingSupport } from "../core/outputBinding";
|
|
2
2
|
import { ElementsRpcClient } from "../core/rpc";
|
|
3
|
-
import { BondEvidenceBundle, OutputBindingSupportEvaluation, OutputBindingSupportMatrix, PolicyEvidenceBundle, PolicyTemplateManifestValidationResult, DefinitionInput, DefinitionVerificationResult, CompileFromFileInput, CompileFromPresetInput, DefinitionDescriptor, StateDocumentDescriptor, StateDocumentInput, StateVerificationResult, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
|
|
3
|
+
import { BondEvidenceBundle, OutputBindingSupportEvaluation, OutputBindingSupportMatrix, PolicyEvidenceBundle, ReceivableEvidenceBundle, PolicyTemplateManifestValidationResult, DefinitionInput, DefinitionVerificationResult, CompileFromFileInput, CompileFromPresetInput, DefinitionDescriptor, StateDocumentDescriptor, StateDocumentInput, StateVerificationResult, SimplicityArtifact, SimplicityClientConfig } from "../core/types";
|
|
4
4
|
import { RelayerClient } from "../gasless/RelayerClient";
|
|
5
5
|
import { GaslessTransferInput, GaslessTransferResult, RelayerClientConfig } from "../gasless/types";
|
|
6
6
|
import { CompiledContract } from "./ContractFactory";
|
|
7
7
|
import { DeployedContract } from "./DeployedContract";
|
|
8
|
-
import { prepareRedemption, prepareClosing, exportFinalityPayload, buildSettlement, verifySettlement, define, executeClosing, executeRedemption, exportEvidence, inspectClosing, inspectRedemption, issue, load, verify, verifyClosing, verifyRedemption } from "../domain/bond";
|
|
9
|
-
import { define as defineFund, verify as verifyFund, load as loadFund, prepareCapitalCall, inspectCapitalCallClaim, executeCapitalCallClaim, inspectCapitalCallRollover, executeCapitalCallRollover, inspectCapitalCallRefund, executeCapitalCallRefund, verifyCapitalCall, signPositionReceipt, verifyPositionReceipt, prepareDistribution, reconcilePosition, inspectDistributionClaim, executeDistributionClaim, verifyDistribution, prepareClosing as prepareFundClosing, verifyClosing as verifyFundClosing, exportEvidence as exportFundEvidence, exportFinalityPayload as exportFundFinalityPayload } from "../domain/fund";
|
|
8
|
+
import { prepareRedemption, prepareClosing, exportFinalityPayload, buildSettlement, verifySettlement, define, executeClosing, executeRedemption, exportEvidence, inspectClosing, inspectRedemption, issue, load, verify, verifyIssuanceHistory, verifyClosing, verifyRedemption } from "../domain/bond";
|
|
9
|
+
import { define as defineFund, verify as verifyFund, load as loadFund, prepareCapitalCall, inspectCapitalCallClaim, executeCapitalCallClaim, inspectCapitalCallRollover, executeCapitalCallRollover, inspectCapitalCallRefund, executeCapitalCallRefund, verifyCapitalCall, signPositionReceipt, verifyPositionReceipt, verifyPositionReceiptChain, prepareDistribution, reconcilePosition, inspectDistributionClaim, executeDistributionClaim, verifyDistribution, prepareClosing as prepareFundClosing, verifyClosing as verifyFundClosing, exportEvidence as exportFundEvidence, exportFinalityPayload as exportFundFinalityPayload } from "../domain/fund";
|
|
10
10
|
import { buildPolicyOutputDescriptor, describePolicyTemplate, listPolicyTemplates, loadPolicyTemplateManifest, executeTransfer as executePolicyTransfer, exportEvidence as exportPolicyEvidence, inspectTransfer as inspectPolicyTransfer, issue as issuePolicy, prepareTransfer as preparePolicyTransfer, validatePolicyTemplateManifest, validatePolicyTemplateParams, verifyState as verifyPolicyState, verifyTransfer as verifyPolicyTransfer } from "../domain/policies";
|
|
11
|
+
import { define as defineReceivable, exportEvidence as exportReceivableEvidence, exportFinalityPayload as exportReceivableFinalityPayload, executeFundingClaim as executeReceivableFundingClaim, executeRepaymentClaim as executeReceivableRepaymentClaim, inspectFundingClaim as inspectReceivableFundingClaim, inspectRepaymentClaim as inspectReceivableRepaymentClaim, load as loadReceivable, prepareClosing as prepareReceivableClosing, prepareFundingClaim as prepareReceivableFundingClaim, prepareFunding as prepareReceivableFunding, prepareRepaymentClaim as prepareReceivableRepaymentClaim, prepareRepayment as prepareReceivableRepayment, prepareWriteOff as prepareReceivableWriteOff, verify as verifyReceivable, verifyClosing as verifyReceivableClosing, verifyFundingClaim as verifyReceivableFundingClaim, verifyFunding as verifyReceivableFunding, verifyRepaymentClaim as verifyReceivableRepaymentClaim, verifyRepayment as verifyReceivableRepayment, verifyStateHistory as verifyReceivableStateHistory, verifyWriteOff as verifyReceivableWriteOff } from "../domain/receivable";
|
|
11
12
|
export declare class SimplicityClient {
|
|
12
13
|
readonly config: SimplicityClientConfig;
|
|
13
14
|
readonly rpc: ElementsRpcClient;
|
|
@@ -36,6 +37,7 @@ export declare class SimplicityClient {
|
|
|
36
37
|
readonly bonds: {
|
|
37
38
|
define: (input: Parameters<typeof define>[1]) => ReturnType<typeof define>;
|
|
38
39
|
verify: (input: Parameters<typeof verify>[1]) => ReturnType<typeof verify>;
|
|
40
|
+
verifyIssuanceHistory: (input: Parameters<typeof verifyIssuanceHistory>[1]) => ReturnType<typeof verifyIssuanceHistory>;
|
|
39
41
|
load: (input: Parameters<typeof load>[1]) => ReturnType<typeof load>;
|
|
40
42
|
issue: (input: Parameters<typeof issue>[1]) => ReturnType<typeof issue>;
|
|
41
43
|
prepareRedemption: (input: Parameters<typeof prepareRedemption>[1]) => ReturnType<typeof prepareRedemption>;
|
|
@@ -65,6 +67,7 @@ export declare class SimplicityClient {
|
|
|
65
67
|
verifyCapitalCall: (input: Parameters<typeof verifyCapitalCall>[1]) => ReturnType<typeof verifyCapitalCall>;
|
|
66
68
|
signPositionReceipt: (input: Parameters<typeof signPositionReceipt>[1]) => ReturnType<typeof signPositionReceipt>;
|
|
67
69
|
verifyPositionReceipt: (input: Parameters<typeof verifyPositionReceipt>[1]) => ReturnType<typeof verifyPositionReceipt>;
|
|
70
|
+
verifyPositionReceiptChain: (input: Parameters<typeof verifyPositionReceiptChain>[1]) => ReturnType<typeof verifyPositionReceiptChain>;
|
|
68
71
|
prepareDistribution: (input: Parameters<typeof prepareDistribution>[1]) => ReturnType<typeof prepareDistribution>;
|
|
69
72
|
reconcilePosition: (input: Parameters<typeof reconcilePosition>[1]) => ReturnType<typeof reconcilePosition>;
|
|
70
73
|
inspectDistributionClaim: (input: Parameters<typeof inspectDistributionClaim>[1]) => ReturnType<typeof inspectDistributionClaim>;
|
|
@@ -75,6 +78,30 @@ export declare class SimplicityClient {
|
|
|
75
78
|
exportEvidence: (input: Parameters<typeof exportFundEvidence>[1]) => ReturnType<typeof exportFundEvidence>;
|
|
76
79
|
exportFinalityPayload: (input: Parameters<typeof exportFundFinalityPayload>[1]) => ReturnType<typeof exportFundFinalityPayload>;
|
|
77
80
|
};
|
|
81
|
+
readonly receivables: {
|
|
82
|
+
define: (input: Parameters<typeof defineReceivable>[1]) => ReturnType<typeof defineReceivable>;
|
|
83
|
+
verify: (input: Parameters<typeof verifyReceivable>[1]) => ReturnType<typeof verifyReceivable>;
|
|
84
|
+
load: (input: Parameters<typeof loadReceivable>[1]) => ReturnType<typeof loadReceivable>;
|
|
85
|
+
prepareFunding: (input: Parameters<typeof prepareReceivableFunding>[1]) => ReturnType<typeof prepareReceivableFunding>;
|
|
86
|
+
verifyFunding: (input: Parameters<typeof verifyReceivableFunding>[1]) => ReturnType<typeof verifyReceivableFunding>;
|
|
87
|
+
prepareFundingClaim: (input: Parameters<typeof prepareReceivableFundingClaim>[1]) => ReturnType<typeof prepareReceivableFundingClaim>;
|
|
88
|
+
inspectFundingClaim: (input: Parameters<typeof inspectReceivableFundingClaim>[1]) => ReturnType<typeof inspectReceivableFundingClaim>;
|
|
89
|
+
executeFundingClaim: (input: Parameters<typeof executeReceivableFundingClaim>[1]) => ReturnType<typeof executeReceivableFundingClaim>;
|
|
90
|
+
verifyFundingClaim: (input: Parameters<typeof verifyReceivableFundingClaim>[1]) => ReturnType<typeof verifyReceivableFundingClaim>;
|
|
91
|
+
prepareRepayment: (input: Parameters<typeof prepareReceivableRepayment>[1]) => ReturnType<typeof prepareReceivableRepayment>;
|
|
92
|
+
verifyRepayment: (input: Parameters<typeof verifyReceivableRepayment>[1]) => ReturnType<typeof verifyReceivableRepayment>;
|
|
93
|
+
prepareRepaymentClaim: (input: Parameters<typeof prepareReceivableRepaymentClaim>[1]) => ReturnType<typeof prepareReceivableRepaymentClaim>;
|
|
94
|
+
inspectRepaymentClaim: (input: Parameters<typeof inspectReceivableRepaymentClaim>[1]) => ReturnType<typeof inspectReceivableRepaymentClaim>;
|
|
95
|
+
executeRepaymentClaim: (input: Parameters<typeof executeReceivableRepaymentClaim>[1]) => ReturnType<typeof executeReceivableRepaymentClaim>;
|
|
96
|
+
verifyRepaymentClaim: (input: Parameters<typeof verifyReceivableRepaymentClaim>[1]) => ReturnType<typeof verifyReceivableRepaymentClaim>;
|
|
97
|
+
prepareWriteOff: (input: Parameters<typeof prepareReceivableWriteOff>[1]) => ReturnType<typeof prepareReceivableWriteOff>;
|
|
98
|
+
verifyWriteOff: (input: Parameters<typeof verifyReceivableWriteOff>[1]) => ReturnType<typeof verifyReceivableWriteOff>;
|
|
99
|
+
prepareClosing: (input: Parameters<typeof prepareReceivableClosing>[1]) => ReturnType<typeof prepareReceivableClosing>;
|
|
100
|
+
verifyClosing: (input: Parameters<typeof verifyReceivableClosing>[1]) => ReturnType<typeof verifyReceivableClosing>;
|
|
101
|
+
verifyStateHistory: (input: Parameters<typeof verifyReceivableStateHistory>[1]) => ReturnType<typeof verifyReceivableStateHistory>;
|
|
102
|
+
exportEvidence: (input: Parameters<typeof exportReceivableEvidence>[1]) => Promise<ReceivableEvidenceBundle>;
|
|
103
|
+
exportFinalityPayload: (input: Parameters<typeof exportReceivableFinalityPayload>[1]) => ReturnType<typeof exportReceivableFinalityPayload>;
|
|
104
|
+
};
|
|
78
105
|
constructor(config: SimplicityClientConfig);
|
|
79
106
|
compileFromFile(input: CompileFromFileInput): Promise<CompiledContract>;
|
|
80
107
|
compileFromPreset(input: CompileFromPresetInput): Promise<CompiledContract>;
|
|
@@ -15,6 +15,7 @@ const DeployedContract_1 = require("./DeployedContract");
|
|
|
15
15
|
const bond_1 = require("../domain/bond");
|
|
16
16
|
const fund_1 = require("../domain/fund");
|
|
17
17
|
const policies_1 = require("../domain/policies");
|
|
18
|
+
const receivable_1 = require("../domain/receivable");
|
|
18
19
|
class SimplicityClient {
|
|
19
20
|
config;
|
|
20
21
|
rpc;
|
|
@@ -23,6 +24,7 @@ class SimplicityClient {
|
|
|
23
24
|
policies;
|
|
24
25
|
bonds;
|
|
25
26
|
funds;
|
|
27
|
+
receivables;
|
|
26
28
|
constructor(config) {
|
|
27
29
|
this.config = config;
|
|
28
30
|
this.rpc = new rpc_1.ElementsRpcClient(config.rpc);
|
|
@@ -51,6 +53,7 @@ class SimplicityClient {
|
|
|
51
53
|
this.bonds = {
|
|
52
54
|
define: async (input) => (0, bond_1.define)(this, input),
|
|
53
55
|
verify: async (input) => (0, bond_1.verify)(this, input),
|
|
56
|
+
verifyIssuanceHistory: async (input) => (0, bond_1.verifyIssuanceHistory)(this, input),
|
|
54
57
|
load: async (input) => (0, bond_1.load)(this, input),
|
|
55
58
|
issue: async (input) => (0, bond_1.issue)(this, input),
|
|
56
59
|
prepareRedemption: async (input) => (0, bond_1.prepareRedemption)(this, input),
|
|
@@ -80,6 +83,7 @@ class SimplicityClient {
|
|
|
80
83
|
verifyCapitalCall: async (input) => (0, fund_1.verifyCapitalCall)(this, input),
|
|
81
84
|
signPositionReceipt: async (input) => (0, fund_1.signPositionReceipt)(this, input),
|
|
82
85
|
verifyPositionReceipt: async (input) => (0, fund_1.verifyPositionReceipt)(this, input),
|
|
86
|
+
verifyPositionReceiptChain: async (input) => (0, fund_1.verifyPositionReceiptChain)(this, input),
|
|
83
87
|
prepareDistribution: async (input) => (0, fund_1.prepareDistribution)(this, input),
|
|
84
88
|
reconcilePosition: async (input) => (0, fund_1.reconcilePosition)(this, input),
|
|
85
89
|
inspectDistributionClaim: async (input) => (0, fund_1.inspectDistributionClaim)(this, input),
|
|
@@ -90,6 +94,30 @@ class SimplicityClient {
|
|
|
90
94
|
exportEvidence: async (input) => (0, fund_1.exportEvidence)(this, input),
|
|
91
95
|
exportFinalityPayload: async (input) => (0, fund_1.exportFinalityPayload)(this, input),
|
|
92
96
|
};
|
|
97
|
+
this.receivables = {
|
|
98
|
+
define: async (input) => (0, receivable_1.define)(this, input),
|
|
99
|
+
verify: async (input) => (0, receivable_1.verify)(this, input),
|
|
100
|
+
load: async (input) => (0, receivable_1.load)(this, input),
|
|
101
|
+
prepareFunding: async (input) => (0, receivable_1.prepareFunding)(this, input),
|
|
102
|
+
verifyFunding: async (input) => (0, receivable_1.verifyFunding)(this, input),
|
|
103
|
+
prepareFundingClaim: async (input) => (0, receivable_1.prepareFundingClaim)(this, input),
|
|
104
|
+
inspectFundingClaim: async (input) => (0, receivable_1.inspectFundingClaim)(this, input),
|
|
105
|
+
executeFundingClaim: async (input) => (0, receivable_1.executeFundingClaim)(this, input),
|
|
106
|
+
verifyFundingClaim: async (input) => (0, receivable_1.verifyFundingClaim)(this, input),
|
|
107
|
+
prepareRepayment: async (input) => (0, receivable_1.prepareRepayment)(this, input),
|
|
108
|
+
verifyRepayment: async (input) => (0, receivable_1.verifyRepayment)(this, input),
|
|
109
|
+
prepareRepaymentClaim: async (input) => (0, receivable_1.prepareRepaymentClaim)(this, input),
|
|
110
|
+
inspectRepaymentClaim: async (input) => (0, receivable_1.inspectRepaymentClaim)(this, input),
|
|
111
|
+
executeRepaymentClaim: async (input) => (0, receivable_1.executeRepaymentClaim)(this, input),
|
|
112
|
+
verifyRepaymentClaim: async (input) => (0, receivable_1.verifyRepaymentClaim)(this, input),
|
|
113
|
+
prepareWriteOff: async (input) => (0, receivable_1.prepareWriteOff)(this, input),
|
|
114
|
+
verifyWriteOff: async (input) => (0, receivable_1.verifyWriteOff)(this, input),
|
|
115
|
+
prepareClosing: async (input) => (0, receivable_1.prepareClosing)(this, input),
|
|
116
|
+
verifyClosing: async (input) => (0, receivable_1.verifyClosing)(this, input),
|
|
117
|
+
verifyStateHistory: async (input) => (0, receivable_1.verifyStateHistory)(this, input),
|
|
118
|
+
exportEvidence: async (input) => (0, receivable_1.exportEvidence)(this, input),
|
|
119
|
+
exportFinalityPayload: async (input) => (0, receivable_1.exportFinalityPayload)(this, input),
|
|
120
|
+
};
|
|
93
121
|
}
|
|
94
122
|
async compileFromFile(input) {
|
|
95
123
|
const artifact = await (0, compiler_1.compileFromFile)(this.config, input);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function verifyHashLinkedLineage<T, K extends string>(input: {
|
|
2
|
+
entries: T[];
|
|
3
|
+
summarize: (entry: T) => {
|
|
4
|
+
hash: string;
|
|
5
|
+
};
|
|
6
|
+
getPreviousHash: (entry: T) => string | null | undefined;
|
|
7
|
+
isGenesis: (entry: T) => boolean;
|
|
8
|
+
consistencyChecks?: Record<K, (entry: T, first: T) => boolean>;
|
|
9
|
+
}): {
|
|
10
|
+
chainLength: number;
|
|
11
|
+
startsAtGenesis: boolean;
|
|
12
|
+
previousHashLinked: boolean;
|
|
13
|
+
consistency: Record<K, boolean>;
|
|
14
|
+
fullLineageVerified: boolean;
|
|
15
|
+
summaries: {
|
|
16
|
+
hash: string;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyHashLinkedLineage = verifyHashLinkedLineage;
|
|
4
|
+
function verifyHashLinkedLineage(input) {
|
|
5
|
+
const entries = [...input.entries];
|
|
6
|
+
if (entries.length === 0) {
|
|
7
|
+
throw new Error("hash-linked lineage requires at least one entry");
|
|
8
|
+
}
|
|
9
|
+
const first = entries[0];
|
|
10
|
+
const summaries = entries.map((entry) => input.summarize(entry));
|
|
11
|
+
const startsAtGenesis = input.isGenesis(first);
|
|
12
|
+
const previousHashLinked = entries.every((entry, index) => (index === 0
|
|
13
|
+
? true
|
|
14
|
+
: input.getPreviousHash(entry) === summaries[index - 1].hash));
|
|
15
|
+
const consistency = Object.fromEntries(Object.entries(input.consistencyChecks ?? {}).map(([label, check]) => [
|
|
16
|
+
label,
|
|
17
|
+
entries.every((entry) => check(entry, first)),
|
|
18
|
+
]));
|
|
19
|
+
const fullLineageVerified = startsAtGenesis
|
|
20
|
+
&& previousHashLinked
|
|
21
|
+
&& Object.values(consistency).every(Boolean);
|
|
22
|
+
return {
|
|
23
|
+
chainLength: entries.length,
|
|
24
|
+
startsAtGenesis,
|
|
25
|
+
previousHashLinked,
|
|
26
|
+
consistency,
|
|
27
|
+
fullLineageVerified,
|
|
28
|
+
summaries,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BondOutputBindingMode, DefinitionVerificationResult, DomainLineageTrust, LineageTrustBase, StateVerificationResult, VerificationTrustSummary } from "./types";
|
|
2
|
+
export declare function buildLineageTrustBase<LineageKind extends string>(input: LineageTrustBase<LineageKind>): LineageTrustBase<LineageKind>;
|
|
3
|
+
export declare function buildVerificationTrustSections<TDefinitionTrust, TStateTrust>(input: {
|
|
4
|
+
definitionTrust?: TDefinitionTrust;
|
|
5
|
+
stateTrust?: TStateTrust;
|
|
6
|
+
requireArtifactTrust?: boolean;
|
|
7
|
+
emptyDefinitionTrust: TDefinitionTrust;
|
|
8
|
+
emptyStateTrust: TStateTrust;
|
|
9
|
+
}): {
|
|
10
|
+
artifactTrust: {
|
|
11
|
+
definition: TDefinitionTrust;
|
|
12
|
+
state: TStateTrust;
|
|
13
|
+
};
|
|
14
|
+
stateTrust: TStateTrust;
|
|
15
|
+
};
|
|
16
|
+
export declare function buildDomainLineageTrustSummary(lineageTrust?: DomainLineageTrust): VerificationTrustSummary["lineage"] | undefined;
|
|
17
|
+
export declare function buildVerificationTrustSummary(input: {
|
|
18
|
+
definitionTrust?: DefinitionVerificationResult["trust"];
|
|
19
|
+
stateTrust?: StateVerificationResult["trust"];
|
|
20
|
+
bindingMode: BondOutputBindingMode;
|
|
21
|
+
lineageTrust?: DomainLineageTrust;
|
|
22
|
+
}): VerificationTrustSummary;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildLineageTrustBase = buildLineageTrustBase;
|
|
4
|
+
exports.buildVerificationTrustSections = buildVerificationTrustSections;
|
|
5
|
+
exports.buildDomainLineageTrustSummary = buildDomainLineageTrustSummary;
|
|
6
|
+
exports.buildVerificationTrustSummary = buildVerificationTrustSummary;
|
|
7
|
+
function buildLineageTrustBase(input) {
|
|
8
|
+
return { ...input };
|
|
9
|
+
}
|
|
10
|
+
function buildVerificationTrustSections(input) {
|
|
11
|
+
void input.requireArtifactTrust;
|
|
12
|
+
const definitionTrust = input.definitionTrust ?? input.emptyDefinitionTrust;
|
|
13
|
+
const stateTrust = input.stateTrust ?? input.emptyStateTrust;
|
|
14
|
+
return {
|
|
15
|
+
artifactTrust: {
|
|
16
|
+
definition: definitionTrust,
|
|
17
|
+
state: stateTrust,
|
|
18
|
+
},
|
|
19
|
+
stateTrust,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function buildDomainLineageTrustSummary(lineageTrust) {
|
|
23
|
+
if (!lineageTrust)
|
|
24
|
+
return undefined;
|
|
25
|
+
return {
|
|
26
|
+
lineageKind: lineageTrust.lineageKind,
|
|
27
|
+
latestOrdinal: lineageTrust.latestOrdinal,
|
|
28
|
+
allHashLinksVerified: lineageTrust.allHashLinksVerified,
|
|
29
|
+
identityConsistent: lineageTrust.identityConsistent,
|
|
30
|
+
fullLineageVerified: lineageTrust.fullLineageVerified,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function buildVerificationTrustSummary(input) {
|
|
34
|
+
return {
|
|
35
|
+
...(input.definitionTrust ? { definition: input.definitionTrust } : {}),
|
|
36
|
+
...(input.stateTrust ? { state: input.stateTrust } : {}),
|
|
37
|
+
bindingMode: input.bindingMode,
|
|
38
|
+
...(input.lineageTrust ? { lineage: buildDomainLineageTrustSummary(input.lineageTrust) } : {}),
|
|
39
|
+
};
|
|
40
|
+
}
|
package/dist/core/schnorr.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function hexToBytes(hex: string, byteLength?: number | null): Uint8Array;
|
|
2
2
|
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
3
|
-
export declare function schnorrPublicKeyFromPrivkeyHex(privkeyHex: string): string
|
|
4
|
-
export declare function schnorrSignHex(messageHashHex: string, privkeyHex: string): string
|
|
5
|
-
export declare function schnorrVerifyHex(signatureHex: string, messageHashHex: string, publicKeyHex: string): boolean
|
|
3
|
+
export declare function schnorrPublicKeyFromPrivkeyHex(privkeyHex: string): Promise<string>;
|
|
4
|
+
export declare function schnorrSignHex(messageHashHex: string, privkeyHex: string): Promise<string>;
|
|
5
|
+
export declare function schnorrVerifyHex(signatureHex: string, messageHashHex: string, publicKeyHex: string): Promise<boolean>;
|
package/dist/core/schnorr.js
CHANGED
|
@@ -5,8 +5,17 @@ exports.bytesToHex = bytesToHex;
|
|
|
5
5
|
exports.schnorrPublicKeyFromPrivkeyHex = schnorrPublicKeyFromPrivkeyHex;
|
|
6
6
|
exports.schnorrSignHex = schnorrSignHex;
|
|
7
7
|
exports.schnorrVerifyHex = schnorrVerifyHex;
|
|
8
|
-
const secp256k1_js_1 = require("@noble/curves/secp256k1.js");
|
|
9
8
|
const errors_1 = require("./errors");
|
|
9
|
+
// Keep native dynamic import intact under CommonJS output so Node can load the ESM-only noble package.
|
|
10
|
+
const nativeImport = new Function("specifier", "return import(specifier);");
|
|
11
|
+
let schnorrPromise;
|
|
12
|
+
async function loadSchnorr() {
|
|
13
|
+
schnorrPromise ??= nativeImport("@noble/curves/secp256k1.js").then((module) => {
|
|
14
|
+
const typed = module;
|
|
15
|
+
return typed.schnorr;
|
|
16
|
+
});
|
|
17
|
+
return schnorrPromise;
|
|
18
|
+
}
|
|
10
19
|
function assertHex(value, byteLength, code, message) {
|
|
11
20
|
if (!/^[0-9a-f]+$/i.test(value) || value.length % 2 !== 0) {
|
|
12
21
|
throw new errors_1.ValidationError(message, { code });
|
|
@@ -23,12 +32,15 @@ function hexToBytes(hex, byteLength = null) {
|
|
|
23
32
|
function bytesToHex(bytes) {
|
|
24
33
|
return Buffer.from(bytes).toString("hex");
|
|
25
34
|
}
|
|
26
|
-
function schnorrPublicKeyFromPrivkeyHex(privkeyHex) {
|
|
27
|
-
|
|
35
|
+
async function schnorrPublicKeyFromPrivkeyHex(privkeyHex) {
|
|
36
|
+
const schnorr = await loadSchnorr();
|
|
37
|
+
return bytesToHex(schnorr.getPublicKey(hexToBytes(privkeyHex, 32)));
|
|
28
38
|
}
|
|
29
|
-
function schnorrSignHex(messageHashHex, privkeyHex) {
|
|
30
|
-
|
|
39
|
+
async function schnorrSignHex(messageHashHex, privkeyHex) {
|
|
40
|
+
const schnorr = await loadSchnorr();
|
|
41
|
+
return bytesToHex(schnorr.sign(hexToBytes(messageHashHex, 32), hexToBytes(privkeyHex, 32)));
|
|
31
42
|
}
|
|
32
|
-
function schnorrVerifyHex(signatureHex, messageHashHex, publicKeyHex) {
|
|
33
|
-
|
|
43
|
+
async function schnorrVerifyHex(signatureHex, messageHashHex, publicKeyHex) {
|
|
44
|
+
const schnorr = await loadSchnorr();
|
|
45
|
+
return schnorr.verify(hexToBytes(signatureHex, 64), hexToBytes(messageHashHex, 32), hexToBytes(publicKeyHex, 32));
|
|
34
46
|
}
|
package/dist/core/types.d.ts
CHANGED
|
@@ -449,12 +449,37 @@ export interface BondClosingDescriptor {
|
|
|
449
449
|
stateHash: string;
|
|
450
450
|
finalSettlementDescriptorHash: string;
|
|
451
451
|
}
|
|
452
|
+
export interface LineageTrustBase<LineageKind extends string> {
|
|
453
|
+
lineageKind: LineageKind;
|
|
454
|
+
chainLength: number;
|
|
455
|
+
latestOrdinal: number;
|
|
456
|
+
allHashLinksVerified: boolean;
|
|
457
|
+
identityConsistent: boolean;
|
|
458
|
+
fullLineageVerified: boolean;
|
|
459
|
+
}
|
|
460
|
+
export interface BondIssuanceLineageTrust extends LineageTrustBase<"state-history"> {
|
|
461
|
+
latestStatus?: BondIssuanceStatus;
|
|
462
|
+
startsAtGenesis: boolean;
|
|
463
|
+
previousStateHashLinked: boolean;
|
|
464
|
+
issuanceIdConsistent: boolean;
|
|
465
|
+
bondIdConsistent: boolean;
|
|
466
|
+
currencyConsistent: boolean;
|
|
467
|
+
controllerConsistent: boolean;
|
|
468
|
+
issuerEntityConsistent: boolean;
|
|
469
|
+
issuedPrincipalConsistent: boolean;
|
|
470
|
+
allPreviousStateHashMatch: boolean;
|
|
471
|
+
allRedemptionArithmeticValid: boolean;
|
|
472
|
+
allStatusProgressionValid: boolean;
|
|
473
|
+
allTransitionIdentitiesMatch: boolean;
|
|
474
|
+
fullHistoryVerified: boolean;
|
|
475
|
+
}
|
|
452
476
|
export interface BondVerificationReport {
|
|
453
477
|
artifactTrust: {
|
|
454
478
|
definition: DefinitionVerificationResult["trust"];
|
|
455
479
|
state: StateVerificationResult["trust"];
|
|
456
480
|
};
|
|
457
481
|
stateTrust: StateVerificationResult["trust"];
|
|
482
|
+
issuanceLineageTrust?: BondIssuanceLineageTrust;
|
|
458
483
|
settlementTrust?: {
|
|
459
484
|
descriptorHashMatch: boolean;
|
|
460
485
|
outputBindingMode: BondOutputBindingMode;
|
|
@@ -510,6 +535,7 @@ export interface BondEvidenceBundle {
|
|
|
510
535
|
hash: string;
|
|
511
536
|
};
|
|
512
537
|
trust: BondVerificationReport;
|
|
538
|
+
trustSummary: VerificationTrustSummary;
|
|
513
539
|
renderedSourceHash?: string;
|
|
514
540
|
sourceVerificationMode: "source-reloaded" | "artifact-only";
|
|
515
541
|
compiled: {
|
|
@@ -518,6 +544,189 @@ export interface BondEvidenceBundle {
|
|
|
518
544
|
contractAddress: string;
|
|
519
545
|
};
|
|
520
546
|
}
|
|
547
|
+
export type ReceivableStatus = "ORIGINATED" | "FUNDED" | "PARTIALLY_REPAID" | "REPAID" | "DEFAULTED";
|
|
548
|
+
export type ReceivableTransitionType = "ORIGINATE" | "FUND" | "REPAY" | "WRITE_OFF";
|
|
549
|
+
export type ReceivableClosingReason = "REPAID" | "DEFAULTED" | "CANCELLED";
|
|
550
|
+
export type ReceivableClaimKind = "FUNDING" | "REPAYMENT";
|
|
551
|
+
export type ReceivableVerificationReportSchemaVersion = "receivable-verification-report/v1";
|
|
552
|
+
export type ReceivableEvidenceBundleSchemaVersion = "receivable-evidence-bundle/v1";
|
|
553
|
+
export type ReceivableFinalityPayloadSchemaVersion = "receivable-finality-payload/v1";
|
|
554
|
+
export interface ReceivableDefinition {
|
|
555
|
+
receivableId: string;
|
|
556
|
+
originatorEntityId: string;
|
|
557
|
+
debtorEntityId: string;
|
|
558
|
+
currencyAssetId: string;
|
|
559
|
+
faceValue: number;
|
|
560
|
+
dueDate: string;
|
|
561
|
+
controllerXonly: string;
|
|
562
|
+
}
|
|
563
|
+
export interface ReceivableStateTransition {
|
|
564
|
+
type: ReceivableTransitionType;
|
|
565
|
+
amount: number;
|
|
566
|
+
at: string;
|
|
567
|
+
}
|
|
568
|
+
export interface ReceivableState {
|
|
569
|
+
stateId: string;
|
|
570
|
+
receivableId: string;
|
|
571
|
+
originatorEntityId: string;
|
|
572
|
+
debtorEntityId: string;
|
|
573
|
+
holderEntityId: string;
|
|
574
|
+
currencyAssetId: string;
|
|
575
|
+
controllerXonly: string;
|
|
576
|
+
faceValue: number;
|
|
577
|
+
outstandingAmount: number;
|
|
578
|
+
repaidAmount: number;
|
|
579
|
+
status: ReceivableStatus;
|
|
580
|
+
createdAt: string;
|
|
581
|
+
previousStateHash?: string | null;
|
|
582
|
+
lastTransition?: ReceivableStateTransition;
|
|
583
|
+
}
|
|
584
|
+
export interface ReceivableClosingDescriptor {
|
|
585
|
+
closingId: string;
|
|
586
|
+
receivableId: string;
|
|
587
|
+
latestStateHash: string;
|
|
588
|
+
latestStatus: ReceivableStatus;
|
|
589
|
+
holderEntityId: string;
|
|
590
|
+
closedAt: string;
|
|
591
|
+
closingReason: ReceivableClosingReason;
|
|
592
|
+
}
|
|
593
|
+
export interface ReceivableClaimDescriptorBase<ClaimKind extends ReceivableClaimKind> {
|
|
594
|
+
claimId: string;
|
|
595
|
+
claimKind: ClaimKind;
|
|
596
|
+
receivableId: string;
|
|
597
|
+
currentStateHash: string;
|
|
598
|
+
currentStatus: ReceivableStatus;
|
|
599
|
+
payerEntityId: string;
|
|
600
|
+
payeeEntityId: string;
|
|
601
|
+
claimantXonly: string;
|
|
602
|
+
currencyAssetId: string;
|
|
603
|
+
amountSat: number;
|
|
604
|
+
eventTimestamp: string;
|
|
605
|
+
}
|
|
606
|
+
export interface ReceivableFundingClaimDescriptor extends ReceivableClaimDescriptorBase<"FUNDING"> {
|
|
607
|
+
}
|
|
608
|
+
export interface ReceivableRepaymentClaimDescriptor extends ReceivableClaimDescriptorBase<"REPAYMENT"> {
|
|
609
|
+
}
|
|
610
|
+
export interface ReceivableTransitionTrust {
|
|
611
|
+
transitionType: ReceivableTransitionType;
|
|
612
|
+
previousStateHashMatch: boolean;
|
|
613
|
+
participantConsistencyValid: boolean;
|
|
614
|
+
statusProgressionValid: boolean;
|
|
615
|
+
arithmeticDeltaValid: boolean;
|
|
616
|
+
createdAtMonotonic: boolean;
|
|
617
|
+
transitionAmountValid: boolean;
|
|
618
|
+
fullTransitionVerified: boolean;
|
|
619
|
+
}
|
|
620
|
+
export interface ReceivableClosingTrust {
|
|
621
|
+
terminalStatusEligible: boolean;
|
|
622
|
+
latestStateHashMatch: boolean;
|
|
623
|
+
closingReasonMatchesStatus: boolean;
|
|
624
|
+
historyTipMatches: boolean;
|
|
625
|
+
lineageProvided: boolean;
|
|
626
|
+
fullClosingVerified: boolean;
|
|
627
|
+
}
|
|
628
|
+
export interface ReceivableClaimTrust {
|
|
629
|
+
claimKind: ReceivableClaimKind;
|
|
630
|
+
generated: boolean;
|
|
631
|
+
stateStatusEligible: boolean;
|
|
632
|
+
receivableIdMatch: boolean;
|
|
633
|
+
currentStateHashMatch: boolean;
|
|
634
|
+
currentStatusMatch: boolean;
|
|
635
|
+
payerEntityMatch: boolean;
|
|
636
|
+
payeeEntityMatch: boolean;
|
|
637
|
+
claimantXonlyMatch: boolean;
|
|
638
|
+
claimantXonlyCommitted: boolean;
|
|
639
|
+
currencyAssetMatch: boolean;
|
|
640
|
+
amountMatch: boolean;
|
|
641
|
+
eventTimestampMatch: boolean;
|
|
642
|
+
bindingMode: BondOutputBindingMode;
|
|
643
|
+
requestedMode?: BondOutputBindingMode;
|
|
644
|
+
supportedForm: OutputBindingSupportedForm;
|
|
645
|
+
reasonCode: OutputBindingReasonCode;
|
|
646
|
+
nextReceiverRuntimeCommitted: boolean;
|
|
647
|
+
nextOutputHashRuntimeBound: boolean;
|
|
648
|
+
nextOutputScriptRuntimeBound: boolean;
|
|
649
|
+
amountRuntimeBound: boolean;
|
|
650
|
+
autoDerived?: boolean;
|
|
651
|
+
fallbackReason?: string;
|
|
652
|
+
bindingInputs?: OutputBindingInputs;
|
|
653
|
+
fullClaimVerified: boolean;
|
|
654
|
+
}
|
|
655
|
+
export interface ReceivableVerificationReport {
|
|
656
|
+
schemaVersion: ReceivableVerificationReportSchemaVersion;
|
|
657
|
+
receivableTrust: {
|
|
658
|
+
receivableIdMatch: boolean;
|
|
659
|
+
originatorMatch: boolean;
|
|
660
|
+
debtorMatch: boolean;
|
|
661
|
+
currencyMatch: boolean;
|
|
662
|
+
controllerMatch: boolean;
|
|
663
|
+
faceValueMatch: boolean;
|
|
664
|
+
arithmeticValid: boolean;
|
|
665
|
+
statusValid: boolean;
|
|
666
|
+
};
|
|
667
|
+
transitionTrust?: ReceivableTransitionTrust;
|
|
668
|
+
closingTrust?: ReceivableClosingTrust;
|
|
669
|
+
fundingClaimTrust?: ReceivableClaimTrust;
|
|
670
|
+
repaymentClaimTrust?: ReceivableClaimTrust;
|
|
671
|
+
stateLineageTrust?: ReceivableStateLineageTrust;
|
|
672
|
+
}
|
|
673
|
+
export interface ReceivableStateLineageTrust extends LineageTrustBase<"state-history"> {
|
|
674
|
+
latestStatus: ReceivableStatus;
|
|
675
|
+
startsAtGenesis: boolean;
|
|
676
|
+
receivableIdConsistent: boolean;
|
|
677
|
+
originatorConsistent: boolean;
|
|
678
|
+
debtorConsistent: boolean;
|
|
679
|
+
currencyConsistent: boolean;
|
|
680
|
+
controllerConsistent: boolean;
|
|
681
|
+
faceValueConsistent: boolean;
|
|
682
|
+
allPreviousStateHashMatch: boolean;
|
|
683
|
+
allArithmeticValid: boolean;
|
|
684
|
+
allStatusProgressionValid: boolean;
|
|
685
|
+
fullHistoryVerified: boolean;
|
|
686
|
+
}
|
|
687
|
+
export interface ReceivableEvidenceBundle {
|
|
688
|
+
schemaVersion: ReceivableEvidenceBundleSchemaVersion;
|
|
689
|
+
definition: {
|
|
690
|
+
canonicalJson: string;
|
|
691
|
+
hash: string;
|
|
692
|
+
};
|
|
693
|
+
state: {
|
|
694
|
+
canonicalJson: string;
|
|
695
|
+
hash: string;
|
|
696
|
+
};
|
|
697
|
+
stateHistory?: Array<{
|
|
698
|
+
canonicalJson: string;
|
|
699
|
+
hash: string;
|
|
700
|
+
}>;
|
|
701
|
+
fundingClaim?: {
|
|
702
|
+
canonicalJson: string;
|
|
703
|
+
hash: string;
|
|
704
|
+
};
|
|
705
|
+
repaymentClaim?: {
|
|
706
|
+
canonicalJson: string;
|
|
707
|
+
hash: string;
|
|
708
|
+
};
|
|
709
|
+
closing?: {
|
|
710
|
+
canonicalJson: string;
|
|
711
|
+
hash: string;
|
|
712
|
+
};
|
|
713
|
+
trust: ReceivableVerificationReport;
|
|
714
|
+
trustSummary: VerificationTrustSummary;
|
|
715
|
+
}
|
|
716
|
+
export interface ReceivableFinalityPayload {
|
|
717
|
+
schemaVersion: ReceivableFinalityPayloadSchemaVersion;
|
|
718
|
+
receivableId: string;
|
|
719
|
+
holderEntityId: string;
|
|
720
|
+
definitionHash: string;
|
|
721
|
+
latestStateHash: string;
|
|
722
|
+
stateHistoryHashes?: string[] | null;
|
|
723
|
+
fundingClaimHash?: string | null;
|
|
724
|
+
repaymentClaimHash?: string | null;
|
|
725
|
+
closingHash?: string | null;
|
|
726
|
+
closingReason?: ReceivableClosingReason | null;
|
|
727
|
+
trust: ReceivableVerificationReport;
|
|
728
|
+
trustSummary: VerificationTrustSummary;
|
|
729
|
+
}
|
|
521
730
|
export type CapitalCallStatus = "OPEN" | "CLAIMED" | "REFUND_ONLY" | "REFUNDED";
|
|
522
731
|
export type CapitalCallStage = "open" | "claimed" | "refund-only" | "refunded";
|
|
523
732
|
export type CapitalCallCutoffMode = "rollover-window";
|
|
@@ -666,13 +875,52 @@ export interface FundVerificationReport {
|
|
|
666
875
|
sequence?: number;
|
|
667
876
|
sequenceMonotonic?: boolean;
|
|
668
877
|
attestingSignerMatch?: boolean;
|
|
878
|
+
previousEnvelopeProvided?: boolean;
|
|
879
|
+
previousReceiptHashMatch?: boolean;
|
|
880
|
+
previousSequenceMatch?: boolean;
|
|
881
|
+
continuityVerified?: boolean;
|
|
669
882
|
};
|
|
883
|
+
receiptChainTrust?: FundReceiptChainTrust;
|
|
670
884
|
closingTrust?: {
|
|
671
885
|
positionReceiptHashMatch: boolean;
|
|
672
886
|
finalDistributionHashesPresent: boolean;
|
|
673
887
|
positionStatusEligible: boolean;
|
|
674
888
|
};
|
|
675
889
|
}
|
|
890
|
+
export interface FundReceiptChainTrust extends LineageTrustBase<"receipt-chain"> {
|
|
891
|
+
latestSequence?: number;
|
|
892
|
+
startsAtGenesis: boolean;
|
|
893
|
+
latestSequenceCovered: boolean;
|
|
894
|
+
sequenceContiguous: boolean;
|
|
895
|
+
fundConsistent: boolean;
|
|
896
|
+
positionConsistent: boolean;
|
|
897
|
+
lpConsistent: boolean;
|
|
898
|
+
callConsistent: boolean;
|
|
899
|
+
currencyConsistent: boolean;
|
|
900
|
+
lpXonlyConsistent: boolean;
|
|
901
|
+
attestingSignerConsistent: boolean;
|
|
902
|
+
allPositionReceiptHashMatch: boolean;
|
|
903
|
+
allSequenceMatch: boolean;
|
|
904
|
+
allSequenceMonotonic: boolean;
|
|
905
|
+
allAttestingSignerMatch: boolean;
|
|
906
|
+
allAttestationVerified: boolean;
|
|
907
|
+
allContinuityVerified: boolean;
|
|
908
|
+
fullChainVerified: boolean;
|
|
909
|
+
}
|
|
910
|
+
export type DomainLineageTrust = BondIssuanceLineageTrust | FundReceiptChainTrust | ReceivableStateLineageTrust;
|
|
911
|
+
export interface DomainLineageTrustSummary {
|
|
912
|
+
lineageKind: DomainLineageTrust["lineageKind"];
|
|
913
|
+
latestOrdinal: number;
|
|
914
|
+
allHashLinksVerified: boolean;
|
|
915
|
+
identityConsistent: boolean;
|
|
916
|
+
fullLineageVerified: boolean;
|
|
917
|
+
}
|
|
918
|
+
export interface VerificationTrustSummary {
|
|
919
|
+
definition?: DefinitionVerificationResult["trust"];
|
|
920
|
+
state?: StateVerificationResult["trust"];
|
|
921
|
+
bindingMode: BondOutputBindingMode;
|
|
922
|
+
lineage?: DomainLineageTrustSummary;
|
|
923
|
+
}
|
|
676
924
|
export interface FundEvidenceBundle {
|
|
677
925
|
schemaVersion: FundEvidenceBundleSchemaVersion;
|
|
678
926
|
artifact?: SimplicityArtifact;
|
|
@@ -705,6 +953,7 @@ export interface FundEvidenceBundle {
|
|
|
705
953
|
hash: string;
|
|
706
954
|
};
|
|
707
955
|
trust: FundVerificationReport;
|
|
956
|
+
trustSummary: VerificationTrustSummary;
|
|
708
957
|
renderedSourceHash?: string;
|
|
709
958
|
sourceVerificationMode: "source-reloaded" | "artifact-only";
|
|
710
959
|
compiled?: {
|
|
@@ -728,11 +977,7 @@ export interface FundFinalityPayload {
|
|
|
728
977
|
closingHash?: string | null;
|
|
729
978
|
bindingMode: BondOutputBindingMode;
|
|
730
979
|
trust: FundVerificationReport;
|
|
731
|
-
trustSummary:
|
|
732
|
-
definition?: DefinitionVerificationResult["trust"];
|
|
733
|
-
state?: StateVerificationResult["trust"];
|
|
734
|
-
bindingMode: BondOutputBindingMode;
|
|
735
|
-
};
|
|
980
|
+
trustSummary: VerificationTrustSummary;
|
|
736
981
|
}
|
|
737
982
|
export interface PolicyReceiver {
|
|
738
983
|
mode: "plain" | "policy";
|
|
@@ -855,6 +1100,7 @@ export interface PolicyEvidenceBundle {
|
|
|
855
1100
|
hash: string;
|
|
856
1101
|
};
|
|
857
1102
|
report: PolicyVerificationReport;
|
|
1103
|
+
trustSummary: VerificationTrustSummary;
|
|
858
1104
|
renderedSourceHash?: string;
|
|
859
1105
|
sourceVerificationMode: "source-reloaded" | "artifact-only";
|
|
860
1106
|
compiled: {
|
|
@@ -20,7 +20,38 @@ fn require_state_anchor() {
|
|
|
20
20
|
assert!(not(jet::eq_256(anchored_state_hash, zero_hash)));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
fn
|
|
23
|
+
fn require_output_shape(expected_output_hash: u256, expected_output_script_hash: u256, binding_mode: u8) {
|
|
24
|
+
match jet::eq_8(binding_mode, 1) {
|
|
25
|
+
true => {
|
|
26
|
+
let actual_output_hash: u256 = match jet::output_hash(0) {
|
|
27
|
+
Some(output_hash : u256) => output_hash,
|
|
28
|
+
None => panic!(),
|
|
29
|
+
};
|
|
30
|
+
assert!(jet::eq_32(jet::num_outputs(), 2));
|
|
31
|
+
assert!(unwrap(jet::output_is_fee(1)));
|
|
32
|
+
assert!(jet::eq_256(actual_output_hash, expected_output_hash));
|
|
33
|
+
},
|
|
34
|
+
false => {
|
|
35
|
+
match jet::eq_8(binding_mode, 2) {
|
|
36
|
+
true => {
|
|
37
|
+
let actual_output_script_hash: u256 = unwrap(jet::output_script_hash(0));
|
|
38
|
+
assert!(jet::eq_32(jet::num_outputs(), 2));
|
|
39
|
+
assert!(unwrap(jet::output_is_fee(1)));
|
|
40
|
+
assert!(jet::eq_256(actual_output_script_hash, expected_output_script_hash));
|
|
41
|
+
},
|
|
42
|
+
false => {},
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fn refund_path(
|
|
49
|
+
expected_output_hash: u256,
|
|
50
|
+
expected_output_script_hash: u256,
|
|
51
|
+
binding_mode: u8,
|
|
52
|
+
lp_signature: Signature
|
|
53
|
+
) {
|
|
54
|
+
require_output_shape(expected_output_hash, expected_output_script_hash, binding_mode);
|
|
24
55
|
let lp: Pubkey = 0x{{LP_XONLY}};
|
|
25
56
|
jet::bip_0340_verify((lp, jet::sig_all_hash()), lp_signature)
|
|
26
57
|
}
|
|
@@ -28,6 +59,9 @@ fn refund_path(lp_signature: Signature) {
|
|
|
28
59
|
fn main() {
|
|
29
60
|
require_definition_anchor();
|
|
30
61
|
require_state_anchor();
|
|
62
|
+
let expected_output_hash: u256 = witness::EXPECTED_PAYOUT_OUTPUT_HASH;
|
|
63
|
+
let expected_output_script_hash: u256 = witness::EXPECTED_PAYOUT_OUTPUT_SCRIPT_HASH;
|
|
64
|
+
let binding_mode: u8 = witness::OUTPUT_BINDING_MODE;
|
|
31
65
|
let signer_signature: Signature = witness::SIGNER_SIGNATURE;
|
|
32
|
-
refund_path(signer_signature)
|
|
66
|
+
refund_path(expected_output_hash, expected_output_script_hash, binding_mode, signer_signature)
|
|
33
67
|
}
|