@bsv/sdk 1.4.23 → 1.5.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 +14 -0
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/transaction/broadcasters/Teranode.js +64 -0
- package/dist/cjs/src/transaction/broadcasters/Teranode.js.map +1 -0
- package/dist/cjs/src/transaction/broadcasters/index.js +3 -1
- package/dist/cjs/src/transaction/broadcasters/index.js.map +1 -1
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js +94 -0
- package/dist/cjs/src/transaction/http/BinaryFetchClient.js.map +1 -0
- package/dist/cjs/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/cjs/src/transaction/http/index.js +3 -1
- package/dist/cjs/src/transaction/http/index.js.map +1 -1
- package/dist/cjs/src/wallet/WalletClient.js +12 -2
- package/dist/cjs/src/wallet/WalletClient.js.map +1 -1
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js +165 -0
- package/dist/cjs/src/wallet/substrates/ReactNativeWebView.js.map +1 -0
- package/dist/cjs/src/wallet/substrates/index.js +3 -1
- package/dist/cjs/src/wallet/substrates/index.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/transaction/broadcasters/Teranode.js +62 -0
- package/dist/esm/src/transaction/broadcasters/Teranode.js.map +1 -0
- package/dist/esm/src/transaction/broadcasters/index.js +1 -0
- package/dist/esm/src/transaction/broadcasters/index.js.map +1 -1
- package/dist/esm/src/transaction/http/BinaryFetchClient.js +90 -0
- package/dist/esm/src/transaction/http/BinaryFetchClient.js.map +1 -0
- package/dist/esm/src/transaction/http/NodejsHttpClient.js.map +1 -1
- package/dist/esm/src/transaction/http/index.js +1 -0
- package/dist/esm/src/transaction/http/index.js.map +1 -1
- package/dist/esm/src/wallet/WalletClient.js +12 -2
- package/dist/esm/src/wallet/WalletClient.js.map +1 -1
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js +137 -0
- package/dist/esm/src/wallet/substrates/ReactNativeWebView.js.map +1 -0
- package/dist/esm/src/wallet/substrates/index.js +1 -0
- package/dist/esm/src/wallet/substrates/index.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/transaction/broadcasters/Teranode.d.ts +25 -0
- package/dist/types/src/transaction/broadcasters/Teranode.d.ts.map +1 -0
- package/dist/types/src/transaction/broadcasters/index.d.ts +1 -0
- package/dist/types/src/transaction/broadcasters/index.d.ts.map +1 -1
- package/dist/types/src/transaction/http/BinaryFetchClient.d.ts +50 -0
- package/dist/types/src/transaction/http/BinaryFetchClient.d.ts.map +1 -0
- package/dist/types/src/transaction/http/index.d.ts +1 -0
- package/dist/types/src/transaction/http/index.d.ts.map +1 -1
- package/dist/types/src/wallet/WalletClient.d.ts.map +1 -1
- package/dist/types/src/wallet/substrates/ReactNativeWebView.d.ts +412 -0
- package/dist/types/src/wallet/substrates/ReactNativeWebView.d.ts.map +1 -0
- package/dist/types/src/wallet/substrates/index.d.ts +1 -0
- package/dist/types/src/wallet/substrates/index.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/wallet.md +453 -14
- package/package.json +1 -1
- package/src/transaction/broadcasters/Teranode.ts +77 -0
- package/src/transaction/broadcasters/index.ts +1 -0
- package/src/transaction/http/BinaryFetchClient.ts +141 -0
- package/src/transaction/http/NodejsHttpClient.ts +1 -1
- package/src/transaction/http/index.ts +1 -0
- package/src/wallet/WalletClient.ts +13 -4
- package/src/wallet/substrates/ReactNativeWebView.ts +560 -0
- package/src/wallet/substrates/index.ts +1 -0
package/docs/wallet.md
CHANGED
|
@@ -1528,20 +1528,15 @@ Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](
|
|
|
1528
1528
|
---
|
|
1529
1529
|
## Classes
|
|
1530
1530
|
|
|
1531
|
-
| |
|
|
1532
|
-
| --- |
|
|
1533
|
-
| [CachedKeyDeriver](#class-cachedkeyderiver) |
|
|
1534
|
-
| [HTTPWalletJSON](#class-httpwalletjson) |
|
|
1535
|
-
| [HTTPWalletWire](#class-httpwalletwire) |
|
|
1536
|
-
| [KeyDeriver](#class-keyderiver) |
|
|
1537
|
-
| [ProtoWallet](#class-protowallet) |
|
|
1538
|
-
| [
|
|
1539
|
-
| [
|
|
1540
|
-
| [WalletError](#class-walleterror) |
|
|
1541
|
-
| [WalletWireProcessor](#class-walletwireprocessor) |
|
|
1542
|
-
| [WalletWireTransceiver](#class-walletwiretransceiver) |
|
|
1543
|
-
| [WindowCWISubstrate](#class-windowcwisubstrate) |
|
|
1544
|
-
| [XDMSubstrate](#class-xdmsubstrate) |
|
|
1531
|
+
| | |
|
|
1532
|
+
| --- | --- |
|
|
1533
|
+
| [CachedKeyDeriver](#class-cachedkeyderiver) | [WalletClient](#class-walletclient) |
|
|
1534
|
+
| [HTTPWalletJSON](#class-httpwalletjson) | [WalletError](#class-walleterror) |
|
|
1535
|
+
| [HTTPWalletWire](#class-httpwalletwire) | [WalletWireProcessor](#class-walletwireprocessor) |
|
|
1536
|
+
| [KeyDeriver](#class-keyderiver) | [WalletWireTransceiver](#class-walletwiretransceiver) |
|
|
1537
|
+
| [ProtoWallet](#class-protowallet) | [WindowCWISubstrate](#class-windowcwisubstrate) |
|
|
1538
|
+
| [ReactNativeWebView](#class-reactnativewebview) | [XDMSubstrate](#class-xdmsubstrate) |
|
|
1539
|
+
| [WERR_REVIEW_ACTIONS](#class-werr_review_actions) | |
|
|
1545
1540
|
|
|
1546
1541
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
1547
1542
|
|
|
@@ -2132,6 +2127,450 @@ See also: [CreateHmacArgs](./wallet.md#interface-createhmacargs), [CreateHmacRes
|
|
|
2132
2127
|
|
|
2133
2128
|
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
2134
2129
|
|
|
2130
|
+
---
|
|
2131
|
+
### Class: ReactNativeWebView
|
|
2132
|
+
|
|
2133
|
+
Facilitates wallet operations over cross-document messaging.
|
|
2134
|
+
|
|
2135
|
+
```ts
|
|
2136
|
+
export default class ReactNativeWebView implements WalletInterface {
|
|
2137
|
+
constructor(domain: string = "*")
|
|
2138
|
+
async invoke(call: CallType, args: any): Promise<any>
|
|
2139
|
+
async createAction(args: {
|
|
2140
|
+
description: DescriptionString5to50Bytes;
|
|
2141
|
+
inputs?: Array<{
|
|
2142
|
+
tx?: BEEF;
|
|
2143
|
+
outpoint: OutpointString;
|
|
2144
|
+
unlockingScript?: HexString;
|
|
2145
|
+
unlockingScriptLength?: PositiveInteger;
|
|
2146
|
+
inputDescription: DescriptionString5to50Bytes;
|
|
2147
|
+
sequenceNumber?: PositiveIntegerOrZero;
|
|
2148
|
+
}>;
|
|
2149
|
+
outputs?: Array<{
|
|
2150
|
+
lockingScript: HexString;
|
|
2151
|
+
satoshis: SatoshiValue;
|
|
2152
|
+
outputDescription: DescriptionString5to50Bytes;
|
|
2153
|
+
basket?: BasketStringUnder300Bytes;
|
|
2154
|
+
customInstructions?: string;
|
|
2155
|
+
tags?: OutputTagStringUnder300Bytes[];
|
|
2156
|
+
}>;
|
|
2157
|
+
lockTime?: PositiveIntegerOrZero;
|
|
2158
|
+
version?: PositiveIntegerOrZero;
|
|
2159
|
+
labels?: LabelStringUnder300Bytes[];
|
|
2160
|
+
options?: {
|
|
2161
|
+
signAndProcess?: BooleanDefaultTrue;
|
|
2162
|
+
acceptDelayedBroadcast?: BooleanDefaultTrue;
|
|
2163
|
+
trustSelf?: "known";
|
|
2164
|
+
knownTxids?: TXIDHexString[];
|
|
2165
|
+
returnTXIDOnly?: BooleanDefaultFalse;
|
|
2166
|
+
noSend?: BooleanDefaultFalse;
|
|
2167
|
+
noSendChange?: OutpointString[];
|
|
2168
|
+
sendWith?: TXIDHexString[];
|
|
2169
|
+
};
|
|
2170
|
+
}): Promise<{
|
|
2171
|
+
txid?: TXIDHexString;
|
|
2172
|
+
tx?: BEEF;
|
|
2173
|
+
noSendChange?: OutpointString[];
|
|
2174
|
+
sendWithResults?: Array<{
|
|
2175
|
+
txid: TXIDHexString;
|
|
2176
|
+
status: "unproven" | "sending" | "failed";
|
|
2177
|
+
}>;
|
|
2178
|
+
signableTransaction?: {
|
|
2179
|
+
tx: BEEF;
|
|
2180
|
+
reference: Base64String;
|
|
2181
|
+
};
|
|
2182
|
+
}>
|
|
2183
|
+
async signAction(args: {
|
|
2184
|
+
spends: Record<PositiveIntegerOrZero, {
|
|
2185
|
+
unlockingScript: HexString;
|
|
2186
|
+
sequenceNumber?: PositiveIntegerOrZero;
|
|
2187
|
+
}>;
|
|
2188
|
+
reference: Base64String;
|
|
2189
|
+
options?: {
|
|
2190
|
+
acceptDelayedBroadcast?: BooleanDefaultTrue;
|
|
2191
|
+
returnTXIDOnly?: BooleanDefaultFalse;
|
|
2192
|
+
noSend?: BooleanDefaultFalse;
|
|
2193
|
+
noSendChange?: OutpointString[];
|
|
2194
|
+
sendWith: TXIDHexString[];
|
|
2195
|
+
};
|
|
2196
|
+
}): Promise<{
|
|
2197
|
+
txid?: TXIDHexString;
|
|
2198
|
+
tx?: BEEF;
|
|
2199
|
+
noSendChange?: OutpointString[];
|
|
2200
|
+
sendWithResults?: Array<{
|
|
2201
|
+
txid: TXIDHexString;
|
|
2202
|
+
status: "unproven" | "sending" | "failed";
|
|
2203
|
+
}>;
|
|
2204
|
+
}>
|
|
2205
|
+
async abortAction(args: {
|
|
2206
|
+
reference: Base64String;
|
|
2207
|
+
}): Promise<{
|
|
2208
|
+
aborted: true;
|
|
2209
|
+
}>
|
|
2210
|
+
async listActions(args: {
|
|
2211
|
+
labels: LabelStringUnder300Bytes[];
|
|
2212
|
+
labelQueryMode?: "any" | "all";
|
|
2213
|
+
includeLabels?: BooleanDefaultFalse;
|
|
2214
|
+
includeInputs?: BooleanDefaultFalse;
|
|
2215
|
+
includeInputSourceLockingScripts?: BooleanDefaultFalse;
|
|
2216
|
+
includeInputUnlockingScripts?: BooleanDefaultFalse;
|
|
2217
|
+
includeOutputs?: BooleanDefaultFalse;
|
|
2218
|
+
includeOutputLockingScripts?: BooleanDefaultFalse;
|
|
2219
|
+
limit?: PositiveIntegerDefault10Max10000;
|
|
2220
|
+
offset?: PositiveIntegerOrZero;
|
|
2221
|
+
}): Promise<{
|
|
2222
|
+
totalActions: PositiveIntegerOrZero;
|
|
2223
|
+
actions: Array<{
|
|
2224
|
+
txid: TXIDHexString;
|
|
2225
|
+
satoshis: SatoshiValue;
|
|
2226
|
+
status: "completed" | "unprocessed" | "sending" | "unproven" | "unsigned" | "nosend" | "nonfinal";
|
|
2227
|
+
isOutgoing: boolean;
|
|
2228
|
+
description: DescriptionString5to50Bytes;
|
|
2229
|
+
labels?: LabelStringUnder300Bytes[];
|
|
2230
|
+
version: PositiveIntegerOrZero;
|
|
2231
|
+
lockTime: PositiveIntegerOrZero;
|
|
2232
|
+
inputs?: Array<{
|
|
2233
|
+
sourceOutpoint: OutpointString;
|
|
2234
|
+
sourceSatoshis: SatoshiValue;
|
|
2235
|
+
sourceLockingScript?: HexString;
|
|
2236
|
+
unlockingScript?: HexString;
|
|
2237
|
+
inputDescription: DescriptionString5to50Bytes;
|
|
2238
|
+
sequenceNumber: PositiveIntegerOrZero;
|
|
2239
|
+
}>;
|
|
2240
|
+
outputs?: Array<{
|
|
2241
|
+
outputIndex: PositiveIntegerOrZero;
|
|
2242
|
+
satoshis: SatoshiValue;
|
|
2243
|
+
lockingScript?: HexString;
|
|
2244
|
+
spendable: boolean;
|
|
2245
|
+
outputDescription: DescriptionString5to50Bytes;
|
|
2246
|
+
basket: BasketStringUnder300Bytes;
|
|
2247
|
+
tags: OutputTagStringUnder300Bytes[];
|
|
2248
|
+
customInstructions?: string;
|
|
2249
|
+
}>;
|
|
2250
|
+
}>;
|
|
2251
|
+
}>
|
|
2252
|
+
async internalizeAction(args: {
|
|
2253
|
+
tx: BEEF;
|
|
2254
|
+
outputs: Array<{
|
|
2255
|
+
outputIndex: PositiveIntegerOrZero;
|
|
2256
|
+
protocol: "wallet payment" | "basket insertion";
|
|
2257
|
+
paymentRemittance?: {
|
|
2258
|
+
derivationPrefix: Base64String;
|
|
2259
|
+
derivationSuffix: Base64String;
|
|
2260
|
+
senderIdentityKey: PubKeyHex;
|
|
2261
|
+
};
|
|
2262
|
+
insertionRemittance?: {
|
|
2263
|
+
basket: BasketStringUnder300Bytes;
|
|
2264
|
+
customInstructions?: string;
|
|
2265
|
+
tags?: OutputTagStringUnder300Bytes[];
|
|
2266
|
+
};
|
|
2267
|
+
}>;
|
|
2268
|
+
description: DescriptionString5to50Bytes;
|
|
2269
|
+
labels?: LabelStringUnder300Bytes[];
|
|
2270
|
+
}): Promise<{
|
|
2271
|
+
accepted: true;
|
|
2272
|
+
}>
|
|
2273
|
+
async listOutputs(args: {
|
|
2274
|
+
basket: BasketStringUnder300Bytes;
|
|
2275
|
+
tags?: OutputTagStringUnder300Bytes[];
|
|
2276
|
+
tagQueryMode?: "all" | "any";
|
|
2277
|
+
include?: "locking scripts" | "entire transactions";
|
|
2278
|
+
includeCustomInstructions?: BooleanDefaultFalse;
|
|
2279
|
+
includeTags?: BooleanDefaultFalse;
|
|
2280
|
+
includeLabels?: BooleanDefaultFalse;
|
|
2281
|
+
limit?: PositiveIntegerDefault10Max10000;
|
|
2282
|
+
offset?: PositiveIntegerOrZero;
|
|
2283
|
+
}): Promise<{
|
|
2284
|
+
totalOutputs: PositiveIntegerOrZero;
|
|
2285
|
+
outputs: Array<{
|
|
2286
|
+
outpoint: OutpointString;
|
|
2287
|
+
satoshis: SatoshiValue;
|
|
2288
|
+
lockingScript?: HexString;
|
|
2289
|
+
tx?: BEEF;
|
|
2290
|
+
spendable: boolean;
|
|
2291
|
+
customInstructions?: string;
|
|
2292
|
+
tags?: OutputTagStringUnder300Bytes[];
|
|
2293
|
+
labels?: LabelStringUnder300Bytes[];
|
|
2294
|
+
}>;
|
|
2295
|
+
}>
|
|
2296
|
+
async relinquishOutput(args: {
|
|
2297
|
+
basket: BasketStringUnder300Bytes;
|
|
2298
|
+
output: OutpointString;
|
|
2299
|
+
}): Promise<{
|
|
2300
|
+
relinquished: true;
|
|
2301
|
+
}>
|
|
2302
|
+
async getPublicKey(args: {
|
|
2303
|
+
identityKey?: true;
|
|
2304
|
+
protocolID?: [
|
|
2305
|
+
SecurityLevel,
|
|
2306
|
+
ProtocolString5To400Bytes
|
|
2307
|
+
];
|
|
2308
|
+
keyID?: KeyIDStringUnder800Bytes;
|
|
2309
|
+
privileged?: BooleanDefaultFalse;
|
|
2310
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2311
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2312
|
+
forSelf?: BooleanDefaultFalse;
|
|
2313
|
+
}): Promise<{
|
|
2314
|
+
publicKey: PubKeyHex;
|
|
2315
|
+
}>
|
|
2316
|
+
async revealCounterpartyKeyLinkage(args: {
|
|
2317
|
+
counterparty: PubKeyHex;
|
|
2318
|
+
verifier: PubKeyHex;
|
|
2319
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2320
|
+
privileged?: BooleanDefaultFalse;
|
|
2321
|
+
}): Promise<{
|
|
2322
|
+
prover: PubKeyHex;
|
|
2323
|
+
verifier: PubKeyHex;
|
|
2324
|
+
counterparty: PubKeyHex;
|
|
2325
|
+
revelationTime: ISOTimestampString;
|
|
2326
|
+
encryptedLinkage: Byte[];
|
|
2327
|
+
encryptedLinkageProof: Byte[];
|
|
2328
|
+
}>
|
|
2329
|
+
async revealSpecificKeyLinkage(args: {
|
|
2330
|
+
counterparty: PubKeyHex;
|
|
2331
|
+
verifier: PubKeyHex;
|
|
2332
|
+
protocolID: [
|
|
2333
|
+
SecurityLevel,
|
|
2334
|
+
ProtocolString5To400Bytes
|
|
2335
|
+
];
|
|
2336
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2337
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2338
|
+
privileged?: BooleanDefaultFalse;
|
|
2339
|
+
}): Promise<{
|
|
2340
|
+
prover: PubKeyHex;
|
|
2341
|
+
verifier: PubKeyHex;
|
|
2342
|
+
counterparty: PubKeyHex;
|
|
2343
|
+
protocolID: [
|
|
2344
|
+
SecurityLevel,
|
|
2345
|
+
ProtocolString5To400Bytes
|
|
2346
|
+
];
|
|
2347
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2348
|
+
encryptedLinkage: Byte[];
|
|
2349
|
+
encryptedLinkageProof: Byte[];
|
|
2350
|
+
proofType: Byte;
|
|
2351
|
+
}>
|
|
2352
|
+
async encrypt(args: {
|
|
2353
|
+
plaintext: Byte[];
|
|
2354
|
+
protocolID: [
|
|
2355
|
+
SecurityLevel,
|
|
2356
|
+
ProtocolString5To400Bytes
|
|
2357
|
+
];
|
|
2358
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2359
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2360
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2361
|
+
privileged?: BooleanDefaultFalse;
|
|
2362
|
+
}): Promise<{
|
|
2363
|
+
ciphertext: Byte[];
|
|
2364
|
+
}>
|
|
2365
|
+
async decrypt(args: {
|
|
2366
|
+
ciphertext: Byte[];
|
|
2367
|
+
protocolID: [
|
|
2368
|
+
SecurityLevel,
|
|
2369
|
+
ProtocolString5To400Bytes
|
|
2370
|
+
];
|
|
2371
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2372
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2373
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2374
|
+
privileged?: BooleanDefaultFalse;
|
|
2375
|
+
}): Promise<{
|
|
2376
|
+
plaintext: Byte[];
|
|
2377
|
+
}>
|
|
2378
|
+
async createHmac(args: {
|
|
2379
|
+
data: Byte[];
|
|
2380
|
+
protocolID: [
|
|
2381
|
+
SecurityLevel,
|
|
2382
|
+
ProtocolString5To400Bytes
|
|
2383
|
+
];
|
|
2384
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2385
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2386
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2387
|
+
privileged?: BooleanDefaultFalse;
|
|
2388
|
+
}): Promise<{
|
|
2389
|
+
hmac: Byte[];
|
|
2390
|
+
}>
|
|
2391
|
+
async verifyHmac(args: {
|
|
2392
|
+
data: Byte[];
|
|
2393
|
+
hmac: Byte[];
|
|
2394
|
+
protocolID: [
|
|
2395
|
+
SecurityLevel,
|
|
2396
|
+
ProtocolString5To400Bytes
|
|
2397
|
+
];
|
|
2398
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2399
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2400
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2401
|
+
privileged?: BooleanDefaultFalse;
|
|
2402
|
+
}): Promise<{
|
|
2403
|
+
valid: true;
|
|
2404
|
+
}>
|
|
2405
|
+
async createSignature(args: {
|
|
2406
|
+
data?: Byte[];
|
|
2407
|
+
hashToDirectlySign?: Byte[];
|
|
2408
|
+
protocolID: [
|
|
2409
|
+
SecurityLevel,
|
|
2410
|
+
ProtocolString5To400Bytes
|
|
2411
|
+
];
|
|
2412
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2413
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2414
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2415
|
+
privileged?: BooleanDefaultFalse;
|
|
2416
|
+
}): Promise<{
|
|
2417
|
+
signature: Byte[];
|
|
2418
|
+
}>
|
|
2419
|
+
async verifySignature(args: {
|
|
2420
|
+
data?: Byte[];
|
|
2421
|
+
hashToDirectlyVerify?: Byte[];
|
|
2422
|
+
signature: Byte[];
|
|
2423
|
+
protocolID: [
|
|
2424
|
+
SecurityLevel,
|
|
2425
|
+
ProtocolString5To400Bytes
|
|
2426
|
+
];
|
|
2427
|
+
keyID: KeyIDStringUnder800Bytes;
|
|
2428
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2429
|
+
counterparty?: PubKeyHex | "self" | "anyone";
|
|
2430
|
+
forSelf?: BooleanDefaultFalse;
|
|
2431
|
+
privileged?: BooleanDefaultFalse;
|
|
2432
|
+
}): Promise<{
|
|
2433
|
+
valid: true;
|
|
2434
|
+
}>
|
|
2435
|
+
async acquireCertificate(args: {
|
|
2436
|
+
type: Base64String;
|
|
2437
|
+
subject: PubKeyHex;
|
|
2438
|
+
serialNumber: Base64String;
|
|
2439
|
+
revocationOutpoint: OutpointString;
|
|
2440
|
+
signature: HexString;
|
|
2441
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2442
|
+
certifier: PubKeyHex;
|
|
2443
|
+
keyringRevealer: PubKeyHex | "certifier";
|
|
2444
|
+
keyringForSubject: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2445
|
+
acquisitionProtocol: "direct" | "issuance";
|
|
2446
|
+
certifierUrl?: string;
|
|
2447
|
+
}): Promise<{
|
|
2448
|
+
type: Base64String;
|
|
2449
|
+
subject: PubKeyHex;
|
|
2450
|
+
serialNumber: Base64String;
|
|
2451
|
+
certifier: PubKeyHex;
|
|
2452
|
+
revocationOutpoint: OutpointString;
|
|
2453
|
+
signature: HexString;
|
|
2454
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2455
|
+
}>
|
|
2456
|
+
async listCertificates(args: {
|
|
2457
|
+
certifiers: PubKeyHex[];
|
|
2458
|
+
types: Base64String[];
|
|
2459
|
+
limit?: PositiveIntegerDefault10Max10000;
|
|
2460
|
+
offset?: PositiveIntegerOrZero;
|
|
2461
|
+
privileged?: BooleanDefaultFalse;
|
|
2462
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2463
|
+
}): Promise<{
|
|
2464
|
+
totalCertificates: PositiveIntegerOrZero;
|
|
2465
|
+
certificates: Array<{
|
|
2466
|
+
type: Base64String;
|
|
2467
|
+
subject: PubKeyHex;
|
|
2468
|
+
serialNumber: Base64String;
|
|
2469
|
+
certifier: PubKeyHex;
|
|
2470
|
+
revocationOutpoint: OutpointString;
|
|
2471
|
+
signature: HexString;
|
|
2472
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2473
|
+
}>;
|
|
2474
|
+
}>
|
|
2475
|
+
async proveCertificate(args: {
|
|
2476
|
+
certificate: {
|
|
2477
|
+
type: Base64String;
|
|
2478
|
+
subject: PubKeyHex;
|
|
2479
|
+
serialNumber: Base64String;
|
|
2480
|
+
certifier: PubKeyHex;
|
|
2481
|
+
revocationOutpoint: OutpointString;
|
|
2482
|
+
signature: HexString;
|
|
2483
|
+
fields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2484
|
+
};
|
|
2485
|
+
fieldsToReveal: CertificateFieldNameUnder50Bytes[];
|
|
2486
|
+
verifier: PubKeyHex;
|
|
2487
|
+
privileged?: BooleanDefaultFalse;
|
|
2488
|
+
privilegedReason?: DescriptionString5to50Bytes;
|
|
2489
|
+
}): Promise<{
|
|
2490
|
+
keyringForVerifier: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2491
|
+
}>
|
|
2492
|
+
async relinquishCertificate(args: {
|
|
2493
|
+
type: Base64String;
|
|
2494
|
+
serialNumber: Base64String;
|
|
2495
|
+
certifier: PubKeyHex;
|
|
2496
|
+
}): Promise<{
|
|
2497
|
+
relinquished: true;
|
|
2498
|
+
}>
|
|
2499
|
+
async discoverByIdentityKey(args: {
|
|
2500
|
+
identityKey: PubKeyHex;
|
|
2501
|
+
limit?: PositiveIntegerDefault10Max10000;
|
|
2502
|
+
offset?: PositiveIntegerOrZero;
|
|
2503
|
+
}): Promise<{
|
|
2504
|
+
totalCertificates: PositiveIntegerOrZero;
|
|
2505
|
+
certificates: Array<{
|
|
2506
|
+
type: Base64String;
|
|
2507
|
+
subject: PubKeyHex;
|
|
2508
|
+
serialNumber: Base64String;
|
|
2509
|
+
certifier: PubKeyHex;
|
|
2510
|
+
revocationOutpoint: OutpointString;
|
|
2511
|
+
signature: HexString;
|
|
2512
|
+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2513
|
+
certifierInfo: {
|
|
2514
|
+
name: EntityNameStringMax100Bytes;
|
|
2515
|
+
iconUrl: EntityIconURLStringMax500Bytes;
|
|
2516
|
+
description: DescriptionString5to50Bytes;
|
|
2517
|
+
trust: PositiveIntegerMax10;
|
|
2518
|
+
};
|
|
2519
|
+
publiclyRevealedKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2520
|
+
decryptedFields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2521
|
+
}>;
|
|
2522
|
+
}>
|
|
2523
|
+
async discoverByAttributes(args: {
|
|
2524
|
+
attributes: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2525
|
+
limit?: PositiveIntegerDefault10Max10000;
|
|
2526
|
+
offset?: PositiveIntegerOrZero;
|
|
2527
|
+
}): Promise<{
|
|
2528
|
+
totalCertificates: PositiveIntegerOrZero;
|
|
2529
|
+
certificates: Array<{
|
|
2530
|
+
type: Base64String;
|
|
2531
|
+
subject: PubKeyHex;
|
|
2532
|
+
serialNumber: Base64String;
|
|
2533
|
+
certifier: PubKeyHex;
|
|
2534
|
+
revocationOutpoint: OutpointString;
|
|
2535
|
+
signature: HexString;
|
|
2536
|
+
fields: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2537
|
+
certifierInfo: {
|
|
2538
|
+
name: EntityNameStringMax100Bytes;
|
|
2539
|
+
iconUrl: EntityIconURLStringMax500Bytes;
|
|
2540
|
+
description: DescriptionString5to50Bytes;
|
|
2541
|
+
trust: PositiveIntegerMax10;
|
|
2542
|
+
};
|
|
2543
|
+
publiclyRevealedKeyring: Record<CertificateFieldNameUnder50Bytes, Base64String>;
|
|
2544
|
+
decryptedFields: Record<CertificateFieldNameUnder50Bytes, string>;
|
|
2545
|
+
}>;
|
|
2546
|
+
}>
|
|
2547
|
+
async isAuthenticated(args: {}): Promise<{
|
|
2548
|
+
authenticated: true;
|
|
2549
|
+
}>
|
|
2550
|
+
async waitForAuthentication(args: {}): Promise<{
|
|
2551
|
+
authenticated: true;
|
|
2552
|
+
}>
|
|
2553
|
+
async getHeight(args: {}): Promise<{
|
|
2554
|
+
height: PositiveInteger;
|
|
2555
|
+
}>
|
|
2556
|
+
async getHeaderForHeight(args: {
|
|
2557
|
+
height: PositiveInteger;
|
|
2558
|
+
}): Promise<{
|
|
2559
|
+
header: HexString;
|
|
2560
|
+
}>
|
|
2561
|
+
async getNetwork(args: {}): Promise<{
|
|
2562
|
+
network: "mainnet" | "testnet";
|
|
2563
|
+
}>
|
|
2564
|
+
async getVersion(args: {}): Promise<{
|
|
2565
|
+
version: VersionString7To30Bytes;
|
|
2566
|
+
}>
|
|
2567
|
+
}
|
|
2568
|
+
```
|
|
2569
|
+
|
|
2570
|
+
See also: [BEEF](./wallet.md#type-beef), [Base64String](./wallet.md#type-base64string), [BasketStringUnder300Bytes](./wallet.md#type-basketstringunder300bytes), [BooleanDefaultFalse](./wallet.md#type-booleandefaultfalse), [BooleanDefaultTrue](./wallet.md#type-booleandefaulttrue), [Byte](./wallet.md#type-byte), [CallType](./wallet.md#type-calltype), [CertificateFieldNameUnder50Bytes](./wallet.md#type-certificatefieldnameunder50bytes), [DescriptionString5to50Bytes](./wallet.md#type-descriptionstring5to50bytes), [EntityIconURLStringMax500Bytes](./wallet.md#type-entityiconurlstringmax500bytes), [EntityNameStringMax100Bytes](./wallet.md#type-entitynamestringmax100bytes), [HexString](./wallet.md#type-hexstring), [ISOTimestampString](./wallet.md#type-isotimestampstring), [KeyIDStringUnder800Bytes](./wallet.md#type-keyidstringunder800bytes), [LabelStringUnder300Bytes](./wallet.md#type-labelstringunder300bytes), [OutpointString](./wallet.md#type-outpointstring), [OutputTagStringUnder300Bytes](./wallet.md#type-outputtagstringunder300bytes), [PositiveInteger](./wallet.md#type-positiveinteger), [PositiveIntegerDefault10Max10000](./wallet.md#type-positiveintegerdefault10max10000), [PositiveIntegerMax10](./wallet.md#type-positiveintegermax10), [PositiveIntegerOrZero](./wallet.md#type-positiveintegerorzero), [ProtocolString5To400Bytes](./wallet.md#type-protocolstring5to400bytes), [PubKeyHex](./wallet.md#type-pubkeyhex), [SatoshiValue](./wallet.md#type-satoshivalue), [SecurityLevel](./wallet.md#type-securitylevel), [TXIDHexString](./wallet.md#type-txidhexstring), [VersionString7To30Bytes](./wallet.md#type-versionstring7to30bytes), [WalletInterface](./wallet.md#interface-walletinterface), [decrypt](./messages.md#variable-decrypt), [encrypt](./messages.md#variable-encrypt)
|
|
2571
|
+
|
|
2572
|
+
Links: [API](#api), [Interfaces](#interfaces), [Classes](#classes), [Functions](#functions), [Types](#types), [Enums](#enums), [Variables](#variables)
|
|
2573
|
+
|
|
2135
2574
|
---
|
|
2136
2575
|
### Class: WERR_REVIEW_ACTIONS
|
|
2137
2576
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BroadcastResponse,
|
|
3
|
+
BroadcastFailure,
|
|
4
|
+
Broadcaster
|
|
5
|
+
} from '../Broadcaster.js'
|
|
6
|
+
import Transaction from '../Transaction.js'
|
|
7
|
+
import { binaryHttpClient, HttpClient } from '../http/index.js'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents an Teranode transaction broadcaster.
|
|
11
|
+
*/
|
|
12
|
+
export default class Teranode implements Broadcaster {
|
|
13
|
+
readonly URL: string
|
|
14
|
+
readonly httpClient: HttpClient
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Constructs an instance of the Teranode broadcaster.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} URL - The URL endpoint for the Teranode API.
|
|
20
|
+
* @param {HttpClient} httpClient - The HTTP client used to make requests to the API, binaryHttpClient by default.
|
|
21
|
+
*/
|
|
22
|
+
constructor(
|
|
23
|
+
URL: string,
|
|
24
|
+
httpClient: HttpClient = binaryHttpClient()
|
|
25
|
+
) {
|
|
26
|
+
this.URL = URL
|
|
27
|
+
this.httpClient = httpClient
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Broadcasts a transaction via Teranode.
|
|
32
|
+
*
|
|
33
|
+
* @param {Transaction} tx - The transaction to be broadcasted.
|
|
34
|
+
* @returns {Promise<BroadcastResponse | BroadcastFailure>} A promise that resolves to either a success or failure response.
|
|
35
|
+
*/
|
|
36
|
+
async broadcast(
|
|
37
|
+
tx: Transaction
|
|
38
|
+
): Promise<BroadcastResponse | BroadcastFailure> {
|
|
39
|
+
const rawTx = tx.toEF()
|
|
40
|
+
const requestOptions = {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
headers: {
|
|
43
|
+
'Content-Type': 'application/octet-stream'
|
|
44
|
+
},
|
|
45
|
+
data: new Blob([new Uint8Array(rawTx)])
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const response = await this.httpClient.request<string>(
|
|
49
|
+
this.URL,
|
|
50
|
+
requestOptions
|
|
51
|
+
)
|
|
52
|
+
if (response.ok) {
|
|
53
|
+
const txid = tx.id('hex')
|
|
54
|
+
return {
|
|
55
|
+
status: 'success',
|
|
56
|
+
txid,
|
|
57
|
+
message: 'broadcast successful'
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
return {
|
|
61
|
+
status: 'error',
|
|
62
|
+
code: response.status.toString() ?? 'ERR_UNKNOWN',
|
|
63
|
+
description: response.data ?? 'Unknown error'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
status: 'error',
|
|
69
|
+
code: '500',
|
|
70
|
+
description:
|
|
71
|
+
typeof error.message === 'string'
|
|
72
|
+
? error.message
|
|
73
|
+
: 'Internal Server Error'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as ARC } from './ARC.js'
|
|
2
2
|
export type { ArcConfig } from './ARC.js'
|
|
3
3
|
export { default as WhatsOnChainBroadcaster } from './WhatsOnChainBroadcaster.js'
|
|
4
|
+
export { default as Teranode } from './Teranode.js'
|
|
4
5
|
export { defaultBroadcaster } from './DefaultBroadcaster.js'
|