@bsv/sdk 1.1.23 → 1.1.25
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/primitives/Curve.js +7 -7
- package/dist/cjs/src/primitives/Curve.js.map +1 -1
- package/dist/cjs/src/primitives/ECDSA.js +394 -71
- package/dist/cjs/src/primitives/ECDSA.js.map +1 -1
- package/dist/cjs/src/primitives/Point.js +103 -23
- package/dist/cjs/src/primitives/Point.js.map +1 -1
- package/dist/cjs/src/primitives/TransactionSignature.js +4 -3
- package/dist/cjs/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/cjs/src/primitives/utils.js +14 -15
- package/dist/cjs/src/primitives/utils.js.map +1 -1
- package/dist/cjs/src/script/Spend.js +4 -4
- package/dist/cjs/src/script/Spend.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +1 -1
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +492 -0
- package/dist/cjs/src/transaction/Beef.js.map +1 -0
- package/dist/cjs/src/transaction/BeefParty.js +97 -0
- package/dist/cjs/src/transaction/BeefParty.js.map +1 -0
- package/dist/cjs/src/transaction/BeefTx.js +123 -0
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -0
- package/dist/cjs/src/transaction/Transaction.js +81 -66
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/src/transaction/index.js +7 -1
- package/dist/cjs/src/transaction/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/primitives/Curve.js +7 -7
- package/dist/esm/src/primitives/Curve.js.map +1 -1
- package/dist/esm/src/primitives/ECDSA.js +394 -71
- package/dist/esm/src/primitives/ECDSA.js.map +1 -1
- package/dist/esm/src/primitives/Point.js +103 -23
- package/dist/esm/src/primitives/Point.js.map +1 -1
- package/dist/esm/src/primitives/TransactionSignature.js +4 -3
- package/dist/esm/src/primitives/TransactionSignature.js.map +1 -1
- package/dist/esm/src/primitives/utils.js +14 -15
- package/dist/esm/src/primitives/utils.js.map +1 -1
- package/dist/esm/src/script/Spend.js +4 -4
- package/dist/esm/src/script/Spend.js.map +1 -1
- package/dist/esm/src/totp/totp.js +1 -1
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +485 -0
- package/dist/esm/src/transaction/Beef.js.map +1 -0
- package/dist/esm/src/transaction/BeefParty.js +93 -0
- package/dist/esm/src/transaction/BeefParty.js.map +1 -0
- package/dist/esm/src/transaction/BeefTx.js +121 -0
- package/dist/esm/src/transaction/BeefTx.js.map +1 -0
- package/dist/esm/src/transaction/Transaction.js +81 -66
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/src/transaction/index.js +3 -0
- package/dist/esm/src/transaction/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/primitives/ECDSA.d.ts.map +1 -1
- package/dist/types/src/primitives/Point.d.ts +5 -0
- package/dist/types/src/primitives/Point.d.ts.map +1 -1
- package/dist/types/src/primitives/TransactionSignature.d.ts.map +1 -1
- package/dist/types/src/primitives/utils.d.ts.map +1 -1
- package/dist/types/src/transaction/Beef.d.ts +143 -0
- package/dist/types/src/transaction/Beef.d.ts.map +1 -0
- package/dist/types/src/transaction/BeefParty.d.ts +62 -0
- package/dist/types/src/transaction/BeefParty.d.ts.map +1 -0
- package/dist/types/src/transaction/BeefTx.d.ts +35 -0
- package/dist/types/src/transaction/BeefTx.d.ts.map +1 -0
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/src/transaction/TransactionInput.d.ts +1 -1
- package/dist/types/src/transaction/TransactionInput.d.ts.map +1 -1
- package/dist/types/src/transaction/index.d.ts +3 -0
- package/dist/types/src/transaction/index.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/docs/primitives.md +373 -55
- package/docs/transaction.md +467 -1
- package/package.json +1 -1
- package/src/primitives/Curve.ts +7 -7
- package/src/primitives/ECDSA.ts +485 -75
- package/src/primitives/Point.ts +110 -25
- package/src/primitives/TransactionSignature.ts +4 -3
- package/src/primitives/utils.ts +15 -11
- package/src/script/Spend.ts +4 -4
- package/src/totp/totp.ts +1 -1
- package/src/transaction/Beef.ts +533 -0
- package/src/transaction/BeefParty.ts +100 -0
- package/src/transaction/BeefTx.ts +121 -0
- package/src/transaction/Transaction.ts +95 -69
- package/src/transaction/TransactionInput.ts +1 -1
- package/src/transaction/__tests/Beef.test.ts +290 -0
- package/src/transaction/__tests/Transaction.benchmarks.test.ts +222 -0
- package/src/transaction/index.ts +3 -0
package/docs/transaction.md
CHANGED
|
@@ -52,7 +52,7 @@ export default interface TransactionInput {
|
|
|
52
52
|
sign: (tx: Transaction, inputIndex: number) => Promise<UnlockingScript>;
|
|
53
53
|
estimateLength: (tx: Transaction, inputIndex: number) => Promise<number>;
|
|
54
54
|
};
|
|
55
|
-
sequence
|
|
55
|
+
sequence?: number;
|
|
56
56
|
}
|
|
57
57
|
```
|
|
58
58
|
|
|
@@ -449,6 +449,9 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
449
449
|
| |
|
|
450
450
|
| --- |
|
|
451
451
|
| [ARC](#class-arc) |
|
|
452
|
+
| [Beef](#class-beef) |
|
|
453
|
+
| [BeefParty](#class-beefparty) |
|
|
454
|
+
| [BeefTx](#class-beeftx) |
|
|
452
455
|
| [FetchHttpClient](#class-fetchhttpclient) |
|
|
453
456
|
| [MerklePath](#class-merklepath) |
|
|
454
457
|
| [NodejsHttpClient](#class-nodejshttpclient) |
|
|
@@ -836,6 +839,319 @@ Argument Details
|
|
|
836
839
|
|
|
837
840
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
838
841
|
|
|
842
|
+
---
|
|
843
|
+
### Class: BeefTx
|
|
844
|
+
|
|
845
|
+
A single bitcoin transaction associated with a `Beef` validity proof set.
|
|
846
|
+
|
|
847
|
+
Simple case is transaction data included directly, either as raw bytes or fully parsed data, or both.
|
|
848
|
+
|
|
849
|
+
Supports 'known' transactions which are represented by just their txid.
|
|
850
|
+
It is assumed that intended consumer of this beef already has validity proof for such a transaction,
|
|
851
|
+
which they can merge if necessary to create a valid beef.
|
|
852
|
+
|
|
853
|
+
```ts
|
|
854
|
+
export default class BeefTx {
|
|
855
|
+
_bumpIndex?: number;
|
|
856
|
+
_tx?: Transaction;
|
|
857
|
+
_rawTx?: number[];
|
|
858
|
+
_txid?: string;
|
|
859
|
+
inputTxids: string[] = [];
|
|
860
|
+
degree: number = 0;
|
|
861
|
+
get bumpIndex(): number | undefined
|
|
862
|
+
set bumpIndex(v: number | undefined)
|
|
863
|
+
get hasProof(): boolean
|
|
864
|
+
get isTxidOnly(): boolean
|
|
865
|
+
get txid()
|
|
866
|
+
get tx()
|
|
867
|
+
get rawTx()
|
|
868
|
+
constructor(tx: Transaction | number[] | string, bumpIndex?: number)
|
|
869
|
+
toWriter(writer: Writer): void
|
|
870
|
+
static fromReader(br: Reader): BeefTx
|
|
871
|
+
}
|
|
872
|
+
```
|
|
873
|
+
|
|
874
|
+
<details>
|
|
875
|
+
|
|
876
|
+
<summary>Class BeefTx Details</summary>
|
|
877
|
+
|
|
878
|
+
#### Constructor
|
|
879
|
+
|
|
880
|
+
```ts
|
|
881
|
+
constructor(tx: Transaction | number[] | string, bumpIndex?: number)
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
Argument Details
|
|
885
|
+
|
|
886
|
+
+ **tx**
|
|
887
|
+
+ If string, must be a valid txid. If `number[]` must be a valid serialized transaction.
|
|
888
|
+
+ **bumpIndex**
|
|
889
|
+
+ If transaction already has a proof in the beef to which it will be added.
|
|
890
|
+
|
|
891
|
+
</details>
|
|
892
|
+
|
|
893
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
894
|
+
|
|
895
|
+
---
|
|
896
|
+
### Class: Beef
|
|
897
|
+
|
|
898
|
+
```ts
|
|
899
|
+
export class Beef {
|
|
900
|
+
bumps: MerklePath[] = [];
|
|
901
|
+
txs: BeefTx[] = [];
|
|
902
|
+
constructor()
|
|
903
|
+
get version(): number
|
|
904
|
+
findTxid(txid: string): BeefTx | undefined
|
|
905
|
+
mergeBump(bump: MerklePath): number
|
|
906
|
+
mergeRawTx(rawTx: number[], bumpIndex?: number): BeefTx
|
|
907
|
+
mergeTransaction(tx: Transaction): BeefTx
|
|
908
|
+
removeExistingTxid(txid: string)
|
|
909
|
+
mergeTxidOnly(txid: string): BeefTx
|
|
910
|
+
mergeBeefTx(btx: BeefTx): BeefTx
|
|
911
|
+
mergeBeef(beef: number[] | Beef)
|
|
912
|
+
isValid(allowTxidOnly?: boolean): boolean
|
|
913
|
+
async verify(chainTracker: ChainTracker, allowTxidOnly?: boolean): Promise<boolean>
|
|
914
|
+
toBinary(): number[]
|
|
915
|
+
toHex(): string
|
|
916
|
+
static fromReader(br: Reader): Beef
|
|
917
|
+
static fromBinary(bin: number[]): Beef
|
|
918
|
+
static fromString(s: string, enc?: "hex" | "utf8" | "base64"): Beef
|
|
919
|
+
sortTxs(): string[]
|
|
920
|
+
clone(): Beef
|
|
921
|
+
trimKnownTxids(knownTxids: string[])
|
|
922
|
+
toLogString(): string
|
|
923
|
+
}
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
<details>
|
|
927
|
+
|
|
928
|
+
<summary>Class Beef Details</summary>
|
|
929
|
+
|
|
930
|
+
#### Method clone
|
|
931
|
+
|
|
932
|
+
```ts
|
|
933
|
+
clone(): Beef
|
|
934
|
+
```
|
|
935
|
+
|
|
936
|
+
Returns
|
|
937
|
+
|
|
938
|
+
a shallow copy of this beef
|
|
939
|
+
|
|
940
|
+
#### Method findTxid
|
|
941
|
+
|
|
942
|
+
```ts
|
|
943
|
+
findTxid(txid: string): BeefTx | undefined
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
Returns
|
|
947
|
+
|
|
948
|
+
`BeefTx` in `txs` with `txid`.
|
|
949
|
+
|
|
950
|
+
Argument Details
|
|
951
|
+
|
|
952
|
+
+ **txid**
|
|
953
|
+
+ of `beefTx` to find
|
|
954
|
+
|
|
955
|
+
#### Method fromBinary
|
|
956
|
+
|
|
957
|
+
Constructs an instance of the Beef class based on the provided binary array
|
|
958
|
+
|
|
959
|
+
```ts
|
|
960
|
+
static fromBinary(bin: number[]): Beef
|
|
961
|
+
```
|
|
962
|
+
|
|
963
|
+
Returns
|
|
964
|
+
|
|
965
|
+
An instance of the Beef class constructed from the binary data
|
|
966
|
+
|
|
967
|
+
Argument Details
|
|
968
|
+
|
|
969
|
+
+ **bin**
|
|
970
|
+
+ The binary array from which to construct BEEF
|
|
971
|
+
|
|
972
|
+
#### Method fromString
|
|
973
|
+
|
|
974
|
+
Constructs an instance of the Beef class based on the provided string
|
|
975
|
+
|
|
976
|
+
```ts
|
|
977
|
+
static fromString(s: string, enc?: "hex" | "utf8" | "base64"): Beef
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
Returns
|
|
981
|
+
|
|
982
|
+
An instance of the Beef class constructed from the string
|
|
983
|
+
|
|
984
|
+
Argument Details
|
|
985
|
+
|
|
986
|
+
+ **s**
|
|
987
|
+
+ The string value from which to construct BEEF
|
|
988
|
+
+ **enc**
|
|
989
|
+
+ The encoding of the string value from which BEEF should be constructed
|
|
990
|
+
|
|
991
|
+
#### Method isValid
|
|
992
|
+
|
|
993
|
+
Sorts `txs` and checks structural validity of beef.
|
|
994
|
+
|
|
995
|
+
Does NOT verify merkle roots.
|
|
996
|
+
|
|
997
|
+
Validity requirements:
|
|
998
|
+
1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
999
|
+
2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
1000
|
+
3. Order of transactions satisfies dependencies before dependents.
|
|
1001
|
+
4. No transactions with duplicate txids.
|
|
1002
|
+
|
|
1003
|
+
```ts
|
|
1004
|
+
isValid(allowTxidOnly?: boolean): boolean
|
|
1005
|
+
```
|
|
1006
|
+
|
|
1007
|
+
Argument Details
|
|
1008
|
+
|
|
1009
|
+
+ **allowTxidOnly**
|
|
1010
|
+
+ optional. If true, transaction txid only is assumed valid
|
|
1011
|
+
|
|
1012
|
+
#### Method mergeBump
|
|
1013
|
+
|
|
1014
|
+
Merge a MerklePath that is assumed to be fully valid.
|
|
1015
|
+
|
|
1016
|
+
```ts
|
|
1017
|
+
mergeBump(bump: MerklePath): number
|
|
1018
|
+
```
|
|
1019
|
+
|
|
1020
|
+
Returns
|
|
1021
|
+
|
|
1022
|
+
index of merged bump
|
|
1023
|
+
|
|
1024
|
+
#### Method mergeRawTx
|
|
1025
|
+
|
|
1026
|
+
Merge a serialized transaction.
|
|
1027
|
+
|
|
1028
|
+
Checks that a transaction with the same txid hasn't already been merged.
|
|
1029
|
+
|
|
1030
|
+
Replaces existing transaction with same txid.
|
|
1031
|
+
|
|
1032
|
+
```ts
|
|
1033
|
+
mergeRawTx(rawTx: number[], bumpIndex?: number): BeefTx
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
Returns
|
|
1037
|
+
|
|
1038
|
+
txid of rawTx
|
|
1039
|
+
|
|
1040
|
+
Argument Details
|
|
1041
|
+
|
|
1042
|
+
+ **bumpIndex**
|
|
1043
|
+
+ Optional. If a number, must be valid index into bumps array.
|
|
1044
|
+
|
|
1045
|
+
#### Method mergeTransaction
|
|
1046
|
+
|
|
1047
|
+
Merge a `Transaction` and any referenced `merklePath` and `sourceTransaction`, recursifely.
|
|
1048
|
+
|
|
1049
|
+
Replaces existing transaction with same txid.
|
|
1050
|
+
|
|
1051
|
+
Attempts to match an existing bump to the new transaction.
|
|
1052
|
+
|
|
1053
|
+
```ts
|
|
1054
|
+
mergeTransaction(tx: Transaction): BeefTx
|
|
1055
|
+
```
|
|
1056
|
+
|
|
1057
|
+
Returns
|
|
1058
|
+
|
|
1059
|
+
txid of tx
|
|
1060
|
+
|
|
1061
|
+
#### Method removeExistingTxid
|
|
1062
|
+
|
|
1063
|
+
Removes an existing transaction from the BEEF, given its TXID
|
|
1064
|
+
|
|
1065
|
+
```ts
|
|
1066
|
+
removeExistingTxid(txid: string)
|
|
1067
|
+
```
|
|
1068
|
+
|
|
1069
|
+
Argument Details
|
|
1070
|
+
|
|
1071
|
+
+ **txid**
|
|
1072
|
+
+ TXID of the transaction to remove
|
|
1073
|
+
|
|
1074
|
+
#### Method sortTxs
|
|
1075
|
+
|
|
1076
|
+
Sort the `txs` by input txid dependency order.
|
|
1077
|
+
|
|
1078
|
+
```ts
|
|
1079
|
+
sortTxs(): string[]
|
|
1080
|
+
```
|
|
1081
|
+
|
|
1082
|
+
Returns
|
|
1083
|
+
|
|
1084
|
+
array of input txids of unproven transactions that aren't included in txs.
|
|
1085
|
+
|
|
1086
|
+
#### Method toBinary
|
|
1087
|
+
|
|
1088
|
+
Returns a binary array representing the serialized BEEF
|
|
1089
|
+
|
|
1090
|
+
```ts
|
|
1091
|
+
toBinary(): number[]
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
Returns
|
|
1095
|
+
|
|
1096
|
+
A binary array representing the BEEF
|
|
1097
|
+
|
|
1098
|
+
#### Method toHex
|
|
1099
|
+
|
|
1100
|
+
Returns a hex string representing the serialized BEEF
|
|
1101
|
+
|
|
1102
|
+
```ts
|
|
1103
|
+
toHex(): string
|
|
1104
|
+
```
|
|
1105
|
+
|
|
1106
|
+
Returns
|
|
1107
|
+
|
|
1108
|
+
A hex string representing the BEEF
|
|
1109
|
+
|
|
1110
|
+
#### Method toLogString
|
|
1111
|
+
|
|
1112
|
+
```ts
|
|
1113
|
+
toLogString(): string
|
|
1114
|
+
```
|
|
1115
|
+
|
|
1116
|
+
Returns
|
|
1117
|
+
|
|
1118
|
+
Summary of `Beef` contents as multi-line string.
|
|
1119
|
+
|
|
1120
|
+
#### Method trimKnownTxids
|
|
1121
|
+
|
|
1122
|
+
Ensure that all the txids in `knownTxids` are txidOnly
|
|
1123
|
+
|
|
1124
|
+
```ts
|
|
1125
|
+
trimKnownTxids(knownTxids: string[])
|
|
1126
|
+
```
|
|
1127
|
+
|
|
1128
|
+
#### Method verify
|
|
1129
|
+
|
|
1130
|
+
Sorts `txs` and confirms validity of transaction data contained in beef
|
|
1131
|
+
by validating structure of this beef and confirming computed merkle roots
|
|
1132
|
+
using `chainTracker`.
|
|
1133
|
+
|
|
1134
|
+
Validity requirements:
|
|
1135
|
+
1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
1136
|
+
2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
1137
|
+
3. Order of transactions satisfies dependencies before dependents.
|
|
1138
|
+
4. No transactions with duplicate txids.
|
|
1139
|
+
|
|
1140
|
+
```ts
|
|
1141
|
+
async verify(chainTracker: ChainTracker, allowTxidOnly?: boolean): Promise<boolean>
|
|
1142
|
+
```
|
|
1143
|
+
|
|
1144
|
+
Argument Details
|
|
1145
|
+
|
|
1146
|
+
+ **chainTracker**
|
|
1147
|
+
+ Used to verify computed merkle path roots for all bump txids.
|
|
1148
|
+
+ **allowTxidOnly**
|
|
1149
|
+
+ optional. If true, transaction txid is assumed valid
|
|
1150
|
+
|
|
1151
|
+
</details>
|
|
1152
|
+
|
|
1153
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1154
|
+
|
|
839
1155
|
---
|
|
840
1156
|
### Class: Transaction
|
|
841
1157
|
|
|
@@ -1308,6 +1624,119 @@ tx.verify(new WhatsOnChain(), new SatoshisPerKilobyte(1))
|
|
|
1308
1624
|
|
|
1309
1625
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1310
1626
|
|
|
1627
|
+
---
|
|
1628
|
+
### Class: BeefParty
|
|
1629
|
+
|
|
1630
|
+
Extends `Beef` that is used to exchange transaction validity data with more than one external party.
|
|
1631
|
+
|
|
1632
|
+
Use `addKnownTxidsForParty` to keep track of who knows what to reduce re-transmission of potentially large transactions.
|
|
1633
|
+
|
|
1634
|
+
Use `getTrimmedBeefForParty` to obtain a `Beef` trimmed of transaction validity data known to a specific party.
|
|
1635
|
+
|
|
1636
|
+
Typical usage scenario:
|
|
1637
|
+
|
|
1638
|
+
1. Query a wallet storage provider for spendable outputs.
|
|
1639
|
+
2. The provider replies with a Beef validating the returned outputs.
|
|
1640
|
+
3. Construct a new transaction using some of the queried outputs as inputs, including Beef validating all the inputs.
|
|
1641
|
+
4. Receive new valid raw transaction after processing and Beef validating change outputs added to original inputs.
|
|
1642
|
+
5. Return to step 1, continuing to build on old and new spendable outputs.
|
|
1643
|
+
|
|
1644
|
+
By default, each Beef is required to be complete and valid: All transactions appear as full serialized bitcoin transactions and
|
|
1645
|
+
each transaction either has a merkle path proof (it has been mined) or all of its input transactions are included.
|
|
1646
|
+
|
|
1647
|
+
The size and redundancy of these Beefs becomes a problem when chained transaction creation out-paces the block mining rate.
|
|
1648
|
+
|
|
1649
|
+
```ts
|
|
1650
|
+
export class BeefParty extends Beef {
|
|
1651
|
+
knownTo: Record<string, Record<string, boolean>> = {};
|
|
1652
|
+
constructor(parties?: string[])
|
|
1653
|
+
isParty(party: string)
|
|
1654
|
+
addParty(party: string)
|
|
1655
|
+
getKnownTxidsForParty(party: string): string[]
|
|
1656
|
+
getTrimmedBeefForParty(party: string): Beef
|
|
1657
|
+
addKnownTxidsForParty(party: string, knownTxids: string[])
|
|
1658
|
+
}
|
|
1659
|
+
```
|
|
1660
|
+
|
|
1661
|
+
<details>
|
|
1662
|
+
|
|
1663
|
+
<summary>Class BeefParty Details</summary>
|
|
1664
|
+
|
|
1665
|
+
#### Constructor
|
|
1666
|
+
|
|
1667
|
+
```ts
|
|
1668
|
+
constructor(parties?: string[])
|
|
1669
|
+
```
|
|
1670
|
+
|
|
1671
|
+
Argument Details
|
|
1672
|
+
|
|
1673
|
+
+ **parties**
|
|
1674
|
+
+ Optional array of initial unique party identifiers.
|
|
1675
|
+
|
|
1676
|
+
#### Property knownTo
|
|
1677
|
+
|
|
1678
|
+
keys are party identifiers.
|
|
1679
|
+
values are records of txids with truthy value for which the party already has validity proof.
|
|
1680
|
+
|
|
1681
|
+
```ts
|
|
1682
|
+
knownTo: Record<string, Record<string, boolean>> = {}
|
|
1683
|
+
```
|
|
1684
|
+
|
|
1685
|
+
#### Method addKnownTxidsForParty
|
|
1686
|
+
|
|
1687
|
+
Make note of additional txids "known" to `party`.
|
|
1688
|
+
|
|
1689
|
+
```ts
|
|
1690
|
+
addKnownTxidsForParty(party: string, knownTxids: string[])
|
|
1691
|
+
```
|
|
1692
|
+
|
|
1693
|
+
Argument Details
|
|
1694
|
+
|
|
1695
|
+
+ **party**
|
|
1696
|
+
+ unique identifier, added if new.
|
|
1697
|
+
|
|
1698
|
+
#### Method addParty
|
|
1699
|
+
|
|
1700
|
+
Adds a new unique party identifier to this `BeefParty`.
|
|
1701
|
+
|
|
1702
|
+
```ts
|
|
1703
|
+
addParty(party: string)
|
|
1704
|
+
```
|
|
1705
|
+
|
|
1706
|
+
#### Method getKnownTxidsForParty
|
|
1707
|
+
|
|
1708
|
+
```ts
|
|
1709
|
+
getKnownTxidsForParty(party: string): string[]
|
|
1710
|
+
```
|
|
1711
|
+
|
|
1712
|
+
Returns
|
|
1713
|
+
|
|
1714
|
+
Array of txids "known" to `party`.
|
|
1715
|
+
|
|
1716
|
+
#### Method getTrimmedBeefForParty
|
|
1717
|
+
|
|
1718
|
+
```ts
|
|
1719
|
+
getTrimmedBeefForParty(party: string): Beef
|
|
1720
|
+
```
|
|
1721
|
+
|
|
1722
|
+
Returns
|
|
1723
|
+
|
|
1724
|
+
trimmed beef of unknown transactions and proofs for `party`
|
|
1725
|
+
|
|
1726
|
+
#### Method isParty
|
|
1727
|
+
|
|
1728
|
+
```ts
|
|
1729
|
+
isParty(party: string)
|
|
1730
|
+
```
|
|
1731
|
+
|
|
1732
|
+
Returns
|
|
1733
|
+
|
|
1734
|
+
`true` if `party` has already beed added to this `BeefParty`.
|
|
1735
|
+
|
|
1736
|
+
</details>
|
|
1737
|
+
|
|
1738
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1739
|
+
|
|
1311
1740
|
---
|
|
1312
1741
|
## Functions
|
|
1313
1742
|
|
|
@@ -1423,3 +1852,40 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
1423
1852
|
---
|
|
1424
1853
|
## Variables
|
|
1425
1854
|
|
|
1855
|
+
| |
|
|
1856
|
+
| --- |
|
|
1857
|
+
| [BEEF_MAGIC](#variable-beef_magic) |
|
|
1858
|
+
| [BEEF_MAGIC_TXID_ONLY_EXTENSION](#variable-beef_magic_txid_only_extension) |
|
|
1859
|
+
| [BEEF_MAGIC_V2](#variable-beef_magic_v2) |
|
|
1860
|
+
|
|
1861
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1862
|
+
|
|
1863
|
+
---
|
|
1864
|
+
|
|
1865
|
+
### Variable: BEEF_MAGIC
|
|
1866
|
+
|
|
1867
|
+
```ts
|
|
1868
|
+
BEEF_MAGIC = 4022206465
|
|
1869
|
+
```
|
|
1870
|
+
|
|
1871
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1872
|
+
|
|
1873
|
+
---
|
|
1874
|
+
### Variable: BEEF_MAGIC_V2
|
|
1875
|
+
|
|
1876
|
+
```ts
|
|
1877
|
+
BEEF_MAGIC_V2 = 4022206466
|
|
1878
|
+
```
|
|
1879
|
+
|
|
1880
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1881
|
+
|
|
1882
|
+
---
|
|
1883
|
+
### Variable: BEEF_MAGIC_TXID_ONLY_EXTENSION
|
|
1884
|
+
|
|
1885
|
+
```ts
|
|
1886
|
+
BEEF_MAGIC_TXID_ONLY_EXTENSION = 4022206465
|
|
1887
|
+
```
|
|
1888
|
+
|
|
1889
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Variables](#variables)
|
|
1890
|
+
|
|
1891
|
+
---
|
package/package.json
CHANGED
package/src/primitives/Curve.ts
CHANGED
|
@@ -136,6 +136,13 @@ export default class Curve {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
constructor () {
|
|
139
|
+
if (typeof globalCurve !== 'undefined') {
|
|
140
|
+
return globalCurve
|
|
141
|
+
} else {
|
|
142
|
+
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
143
|
+
globalCurve = this
|
|
144
|
+
}
|
|
145
|
+
|
|
139
146
|
const precomputed = {
|
|
140
147
|
doubles: {
|
|
141
148
|
step: 4,
|
|
@@ -916,13 +923,6 @@ export default class Curve {
|
|
|
916
923
|
]
|
|
917
924
|
}
|
|
918
925
|
}
|
|
919
|
-
|
|
920
|
-
if (typeof globalCurve !== 'undefined') {
|
|
921
|
-
return globalCurve
|
|
922
|
-
} else {
|
|
923
|
-
/* eslint-disable @typescript-eslint/no-this-alias */
|
|
924
|
-
globalCurve = this
|
|
925
|
-
}
|
|
926
926
|
const conf = {
|
|
927
927
|
prime: 'k256',
|
|
928
928
|
p: 'ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f',
|