@ecency/sdk 2.2.2 → 2.2.3

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.
@@ -0,0 +1,955 @@
1
+ declare class Signature {
2
+ data: Uint8Array;
3
+ recovery: number;
4
+ private compressed;
5
+ /**
6
+ * Creates a new Signature instance.
7
+ * @param data Raw signature data (64 bytes)
8
+ * @param recovery Recovery byte (0-3)
9
+ * @param compressed Whether signature is compressed (default: true)
10
+ */
11
+ constructor(data: Uint8Array, recovery: number, compressed?: boolean);
12
+ /**
13
+ * Creates a Signature from a hex string.
14
+ * @param string 130-character hex string containing signature and recovery data
15
+ * @returns New Signature instance
16
+ * @throws Error if input is not a string
17
+ */
18
+ static from(string: string): Signature;
19
+ /**
20
+ * Converts signature to 65-byte buffer format.
21
+ * @returns 65-byte buffer containing recovery byte + signature data
22
+ */
23
+ toBuffer(): Uint8Array<ArrayBuffer>;
24
+ /**
25
+ * Returns signature as 130-character hex string.
26
+ * @returns Hex string representation of signature
27
+ */
28
+ customToString(): string;
29
+ /**
30
+ * Returns signature as 130-character hex string.
31
+ * Overrides Object.prototype.toString() so that String(sig) and
32
+ * template literals produce the hex representation instead of "[object Object]".
33
+ * @returns Hex string representation of signature
34
+ */
35
+ toString(): string;
36
+ /**
37
+ * Recovers the public key from this signature and message.
38
+ * @param message 32-byte message hash (Uint8Array) or 64-character hex string
39
+ * @returns PublicKey that created this signature
40
+ * @throws Error if message is not a valid 32-byte SHA256 hash
41
+ */
42
+ getPublicKey(message: Uint8Array | string): PublicKey;
43
+ }
44
+
45
+ declare class PublicKey {
46
+ key: Uint8Array;
47
+ prefix: string;
48
+ /**
49
+ * Creates a new PublicKey instance from raw bytes.
50
+ * @param key Raw public key bytes (33 bytes, compressed format)
51
+ * @param prefix Optional address prefix (defaults to config.address_prefix)
52
+ */
53
+ constructor(key: Uint8Array, prefix?: string);
54
+ /**
55
+ * Creates a PublicKey from a string representation.
56
+ * @param wif Public key string (e.g., "STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA")
57
+ * @returns New PublicKey instance
58
+ * @throws Error if the key format is invalid
59
+ */
60
+ static fromString(wif: string): PublicKey;
61
+ /**
62
+ * Creates a PublicKey from a string or returns the instance if already a PublicKey.
63
+ * @param value Public key string or PublicKey instance
64
+ * @returns New or existing PublicKey instance
65
+ */
66
+ static from(value: string | PublicKey): PublicKey;
67
+ /**
68
+ * Verifies a signature against a message hash.
69
+ * @param message 32-byte message hash to verify
70
+ * @param signature Signature to verify
71
+ * @returns True if signature is valid, false otherwise
72
+ */
73
+ verify(message: Uint8Array, signature: Signature | string): boolean;
74
+ /**
75
+ * Returns the public key as a string for storage or transmission.
76
+ * @returns Public key string with prefix (e.g., "STM8m5UgaFAAYQRuaNejYdS8FVLVp9Ss3K1qAVk5de6F8s3HnVbvA")
77
+ */
78
+ toString(): string;
79
+ /**
80
+ * Returns JSON representation (same as toString()).
81
+ * @returns Public key string
82
+ */
83
+ toJSON(): string;
84
+ /**
85
+ * Returns a string representation for debugging.
86
+ * @returns Formatted public key string
87
+ */
88
+ inspect(): string;
89
+ }
90
+
91
+ type KeyRole = 'owner' | 'active' | 'posting' | 'memo';
92
+ /**
93
+ * ECDSA (secp256k1) private key for signing and encryption operations.
94
+ * Handles key generation, derivation from seeds/passwords, and cryptographic operations.
95
+ *
96
+ * All private keys are stored internally as Uint8Array and can be converted to/from
97
+ * Wallet Import Format (WIF) strings for storage and transmission.
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * // From WIF string
102
+ * const key = PrivateKey.from('5JdeC9P7Pbd1uGdFVEsJ41EkEnADbbHGq6p1BwFxm6txNBsQnsw')
103
+ *
104
+ * // Generate random key
105
+ * const randomKey = PrivateKey.randomKey()
106
+ *
107
+ * // From username and password
108
+ * const loginKey = PrivateKey.fromLogin('username', 'password')
109
+ *
110
+ * // Sign a message
111
+ * const signature = key.sign(someHash)
112
+ *
113
+ * // Get public key
114
+ * const pubKey = key.createPublic()
115
+ * ```
116
+ */
117
+ declare class PrivateKey {
118
+ key: Uint8Array;
119
+ constructor(key: Uint8Array);
120
+ /**
121
+ * Creates a PrivateKey instance from a WIF string or raw Uint8Array.
122
+ * Automatically detects the input type and uses the appropriate method.
123
+ *
124
+ * @param value - WIF formatted string or raw 32-byte key as Uint8Array
125
+ * @returns New PrivateKey instance
126
+ * @throws Error if the key format is invalid
127
+ */
128
+ static from(value: string | Uint8Array): PrivateKey;
129
+ /**
130
+ * Creates a PrivateKey from a Wallet Import Format (WIF) encoded string.
131
+ *
132
+ * @param wif - WIF encoded private key string
133
+ * @returns New PrivateKey instance
134
+ * @throws Error if WIF format is invalid or checksum fails
135
+ */
136
+ static fromString(wif: string): PrivateKey;
137
+ /**
138
+ * Creates a PrivateKey from a seed string or Uint8Array.
139
+ * The seed is hashed with SHA256 to produce the private key.
140
+ *
141
+ * @param seed - Seed string (converted to bytes) or raw byte array
142
+ * @returns New PrivateKey instance derived from seed
143
+ */
144
+ static fromSeed(seed: string | Uint8Array): PrivateKey;
145
+ /**
146
+ * Derives a PrivateKey from username, password, and role using Hive's key derivation scheme.
147
+ * This generates the same keys that the Hive wallet uses for login-based keys.
148
+ *
149
+ * @param username - Hive username
150
+ * @param password - Master password (or seed phrase)
151
+ * @param role - Key role ('owner', 'active', 'posting', 'memo')
152
+ * @returns New PrivateKey instance for the specified role
153
+ */
154
+ static fromLogin(username: string, password: string, role?: KeyRole): PrivateKey;
155
+ /**
156
+ * Signs a 32-byte message hash using ECDSA and returns a recoverable signature.
157
+ * The signature includes recovery information to allow public key recovery.
158
+ *
159
+ * @param message - 32-byte message hash to sign (Uint8Array)
160
+ * @returns Signature object containing the signature data
161
+ */
162
+ sign(message: Uint8Array): Signature;
163
+ /**
164
+ * Derives the corresponding public key for this private key.
165
+ *
166
+ * @param prefix - Optional address prefix (defaults to config.address_prefix)
167
+ * @returns PublicKey instance derived from this private key
168
+ */
169
+ createPublic(prefix?: string): PublicKey;
170
+ /**
171
+ * Returns the private key as a Wallet Import Format (WIF) encoded string.
172
+ * This includes network ID and checksum for safe storage/transmission.
173
+ *
174
+ * @returns WIF encoded private key string
175
+ */
176
+ toString(): string;
177
+ /**
178
+ * Returns a masked representation of the private key for debugging/logging.
179
+ * Shows only the first and last 6 characters to avoid accidental exposure.
180
+ * Use toString() to get the full key for export/serialization.
181
+ *
182
+ * @returns Masked key representation for safe logging
183
+ */
184
+ inspect(): string;
185
+ /**
186
+ * Computes a shared secret using ECDH key exchange for memo encryption.
187
+ * The shared secret is used as a key for AES encryption/decryption.
188
+ *
189
+ * @param publicKey - Other party's public key
190
+ * @returns 64-byte shared secret as Uint8Array
191
+ */
192
+ getSharedSecret(publicKey: PublicKey): Uint8Array;
193
+ /**
194
+ * Generates a new cryptographically secure random private key.
195
+ * Uses the secp256k1 key generation algorithm for security.
196
+ * This method may take up to 250ms due to entropy collection.
197
+ *
198
+ * @returns New randomly generated PrivateKey instance
199
+ */
200
+ static randomKey(): PrivateKey;
201
+ }
202
+
203
+ /** Class representing a hive asset,
204
+ * e.g. `1.000 HIVE` or `12.112233 VESTS`. */
205
+ declare class Asset {
206
+ amount: number;
207
+ symbol: string;
208
+ constructor(amount: number, symbol: string);
209
+ /** Create a new Asset instance from a string, e.g. `42.000 HIVE`. */
210
+ static fromString(string: string, expectedSymbol?: string | null): Asset;
211
+ /**
212
+ * Convenience to create new Asset.
213
+ * @param symbol Symbol to use when created from number. Will also be used to validate
214
+ * the asset, throws if the passed value has a different symbol than this.
215
+ */
216
+ static from(value: number | string | Asset, symbol?: string | null): Asset;
217
+ /** Return asset precision. */
218
+ getPrecision(): 3 | 6;
219
+ /** Return a string representation of this asset, e.g. `42.000 HIVE`. */
220
+ toString(): string;
221
+ toJSON(): string;
222
+ }
223
+
224
+ type AssetSymbol = 'HIVE' | 'HBD' | 'VESTS' | 'STEEM' | 'SBD' | 'TESTS' | 'TBD';
225
+ interface Authority {
226
+ weight_threshold: number;
227
+ account_auths: Array<[string, number]>;
228
+ key_auths: Array<[string | PublicKey, number]>;
229
+ }
230
+ interface Beneficiary {
231
+ account: string;
232
+ weight: number;
233
+ }
234
+ interface Price {
235
+ base: Asset | string;
236
+ quote: Asset | string;
237
+ }
238
+ interface ChainProperties {
239
+ account_creation_fee: Asset | string;
240
+ maximum_block_size: number;
241
+ hbd_interest_rate: number;
242
+ }
243
+ interface WitnessProps$1 {
244
+ account_creation_fee?: Asset | string;
245
+ account_subsidy_budget?: number;
246
+ account_subsidy_decay?: number;
247
+ key?: string | PublicKey;
248
+ maximum_block_size?: number;
249
+ new_signing_key?: string | PublicKey | null;
250
+ hbd_exchange_rate?: Price;
251
+ hbd_interest_rate?: number;
252
+ url?: string;
253
+ }
254
+ interface VoteOperation {
255
+ voter: string;
256
+ author: string;
257
+ permlink: string;
258
+ weight: number;
259
+ }
260
+ interface CommentOperation {
261
+ parent_author: string;
262
+ parent_permlink: string;
263
+ author: string;
264
+ permlink: string;
265
+ title: string;
266
+ body: string;
267
+ json_metadata: string;
268
+ }
269
+ interface TransferOperation {
270
+ from: string;
271
+ to: string;
272
+ amount: Asset | string;
273
+ memo: string;
274
+ }
275
+ interface TransferToVestingOperation {
276
+ from: string;
277
+ to: string;
278
+ amount: Asset | string;
279
+ }
280
+ interface WithdrawVestingOperation {
281
+ account: string;
282
+ vesting_shares: Asset | string;
283
+ }
284
+ interface AccountCreateOperation {
285
+ fee: Asset | string;
286
+ creator: string;
287
+ new_account_name: string;
288
+ owner: Authority;
289
+ active: Authority;
290
+ posting: Authority;
291
+ memo_key: string | PublicKey;
292
+ json_metadata: string;
293
+ }
294
+ interface AccountCreateWithDelegationOperation {
295
+ fee: Asset | string;
296
+ delegation: Asset | string;
297
+ creator: string;
298
+ new_account_name: string;
299
+ owner: Authority;
300
+ active: Authority;
301
+ posting: Authority;
302
+ memo_key: string | PublicKey;
303
+ json_metadata: string;
304
+ extensions: [];
305
+ }
306
+ interface AccountUpdateOperation {
307
+ account: string;
308
+ owner?: Authority;
309
+ active?: Authority;
310
+ posting?: Authority;
311
+ memo_key: string | PublicKey;
312
+ json_metadata: string;
313
+ }
314
+ interface AccountUpdate2Operation {
315
+ account: string;
316
+ owner?: Authority;
317
+ active?: Authority;
318
+ posting?: Authority;
319
+ memo_key?: string | PublicKey;
320
+ json_metadata: string;
321
+ posting_json_metadata: string;
322
+ extensions: [];
323
+ }
324
+ interface AccountWitnessVoteOperation {
325
+ account: string;
326
+ witness: string;
327
+ approve: boolean;
328
+ }
329
+ interface AccountWitnessProxyOperation {
330
+ account: string;
331
+ proxy: string;
332
+ }
333
+ interface ConvertOperation {
334
+ owner: string;
335
+ requestid: number;
336
+ amount: Asset | string;
337
+ }
338
+ interface CollateralizedConvertOperation {
339
+ owner: string;
340
+ requestid: number;
341
+ amount: Asset | string;
342
+ }
343
+ interface CustomOperation {
344
+ required_auths: string[];
345
+ id: number;
346
+ data: Uint8Array | string;
347
+ }
348
+ interface CustomJsonOperation {
349
+ required_auths: string[];
350
+ required_posting_auths: string[];
351
+ id: string;
352
+ json: string;
353
+ }
354
+ interface ClaimAccountOperation {
355
+ creator: string;
356
+ fee: Asset | string;
357
+ extensions: [];
358
+ }
359
+ interface CreateClaimedAccountOperation {
360
+ creator: string;
361
+ new_account_name: string;
362
+ owner: Authority;
363
+ active: Authority;
364
+ posting: Authority;
365
+ memo_key: string | PublicKey;
366
+ json_metadata: string;
367
+ extensions: [];
368
+ }
369
+ interface ClaimRewardBalanceOperation {
370
+ account: string;
371
+ reward_hive: Asset | string;
372
+ reward_hbd: Asset | string;
373
+ reward_vests: Asset | string;
374
+ }
375
+ interface DelegateVestingSharesOperation {
376
+ delegator: string;
377
+ delegatee: string;
378
+ vesting_shares: Asset | string;
379
+ }
380
+ interface DeleteCommentOperation {
381
+ author: string;
382
+ permlink: string;
383
+ }
384
+ interface CommentOptionsOperation {
385
+ author: string;
386
+ permlink: string;
387
+ max_accepted_payout: Asset | string;
388
+ percent_hbd: number;
389
+ allow_votes: boolean;
390
+ allow_curation_rewards: boolean;
391
+ extensions: [number, {
392
+ beneficiaries: Beneficiary[];
393
+ }][];
394
+ }
395
+ interface SetWithdrawVestingRouteOperation {
396
+ from_account: string;
397
+ to_account: string;
398
+ percent: number;
399
+ auto_vest: boolean;
400
+ }
401
+ interface WitnessUpdateOperation {
402
+ owner: string;
403
+ url: string;
404
+ block_signing_key: string | PublicKey;
405
+ props: ChainProperties;
406
+ fee: Asset | string;
407
+ }
408
+ interface WitnessSetPropertiesOperation {
409
+ owner: string;
410
+ props: Array<[string, string]>;
411
+ extensions: [];
412
+ }
413
+ interface DeclineVotingRightsOperation {
414
+ account: string;
415
+ decline: boolean;
416
+ }
417
+ interface ResetAccountOperation {
418
+ reset_account: string;
419
+ account_to_reset: string;
420
+ new_owner_authority: Authority;
421
+ }
422
+ interface SetResetAccountOperation {
423
+ account: string;
424
+ current_reset_account: string;
425
+ reset_account: string;
426
+ }
427
+ interface TransferToSavingsOperation {
428
+ from: string;
429
+ to: string;
430
+ amount: Asset | string;
431
+ memo: string;
432
+ }
433
+ interface TransferFromSavingsOperation {
434
+ from: string;
435
+ request_id: number;
436
+ to: string;
437
+ amount: Asset | string;
438
+ memo: string;
439
+ }
440
+ interface CancelTransferFromSavingsOperation {
441
+ from: string;
442
+ request_id: number;
443
+ }
444
+ interface LimitOrderCreateOperation {
445
+ owner: string;
446
+ orderid: number;
447
+ amount_to_sell: Asset | string;
448
+ min_to_receive: Asset | string;
449
+ fill_or_kill: boolean;
450
+ expiration: string | Date;
451
+ }
452
+ interface LimitOrderCreate2Operation {
453
+ owner: string;
454
+ orderid: number;
455
+ amount_to_sell: Asset | string;
456
+ fill_or_kill: boolean;
457
+ exchange_rate: Price;
458
+ expiration: string | Date;
459
+ }
460
+ interface LimitOrderCancelOperation {
461
+ owner: string;
462
+ orderid: number;
463
+ }
464
+ interface FeedPublishOperation {
465
+ publisher: string;
466
+ exchange_rate: Price;
467
+ }
468
+ interface EscrowTransferOperation {
469
+ from: string;
470
+ to: string;
471
+ hbd_amount: Asset | string;
472
+ hive_amount: Asset | string;
473
+ escrow_id: number;
474
+ agent: string;
475
+ fee: Asset | string;
476
+ json_meta: string;
477
+ ratification_deadline: string | Date;
478
+ escrow_expiration: string | Date;
479
+ }
480
+ interface EscrowDisputeOperation {
481
+ from: string;
482
+ to: string;
483
+ agent: string;
484
+ who: string;
485
+ escrow_id: number;
486
+ }
487
+ interface EscrowReleaseOperation {
488
+ from: string;
489
+ to: string;
490
+ agent: string;
491
+ who: string;
492
+ receiver: string;
493
+ escrow_id: number;
494
+ hbd_amount: Asset | string;
495
+ hive_amount: Asset | string;
496
+ }
497
+ interface EscrowApproveOperation {
498
+ from: string;
499
+ to: string;
500
+ agent: string;
501
+ who: string;
502
+ escrow_id: number;
503
+ approve: boolean;
504
+ }
505
+ interface RecoverAccountOperation {
506
+ account_to_recover: string;
507
+ new_owner_authority: Authority;
508
+ recent_owner_authority: Authority;
509
+ extensions: [];
510
+ }
511
+ interface RequestAccountRecoveryOperation {
512
+ recovery_account: string;
513
+ account_to_recover: string;
514
+ new_owner_authority: Authority;
515
+ extensions: [];
516
+ }
517
+ interface ChangeRecoveryAccountOperation {
518
+ account_to_recover: string;
519
+ new_recovery_account: string;
520
+ extensions: [];
521
+ }
522
+ interface RecurrentTransferOperation {
523
+ from: string;
524
+ to: string;
525
+ amount: Asset | string;
526
+ memo: string;
527
+ recurrence: number;
528
+ executions: number;
529
+ extensions: Array<{
530
+ type: number;
531
+ value: {
532
+ pair_id: number;
533
+ };
534
+ }>;
535
+ }
536
+ interface CreateProposalOperation {
537
+ creator: string;
538
+ receiver: string;
539
+ start_date: string | Date;
540
+ end_date: string | Date;
541
+ daily_pay: Asset | string;
542
+ subject: string;
543
+ permlink: string;
544
+ extensions: [];
545
+ }
546
+ interface UpdateProposalOperation {
547
+ proposal_id: number;
548
+ creator: string;
549
+ daily_pay: Asset | string;
550
+ subject: string;
551
+ permlink: string;
552
+ extensions: [number, {
553
+ end_date: string;
554
+ }][];
555
+ }
556
+ interface UpdateProposalVotesOperation {
557
+ voter: string;
558
+ proposal_ids: number[];
559
+ approve: boolean;
560
+ extensions: [];
561
+ }
562
+ interface RemoveProposalOperation {
563
+ proposal_owner: string;
564
+ proposal_ids: number[];
565
+ extensions: [];
566
+ }
567
+ type Operation = ['vote', VoteOperation] | ['comment', CommentOperation] | ['transfer', TransferOperation] | ['transfer_to_vesting', TransferToVestingOperation] | ['withdraw_vesting', WithdrawVestingOperation] | ['account_create', AccountCreateOperation] | ['account_create_with_delegation', AccountCreateWithDelegationOperation] | ['account_update', AccountUpdateOperation] | ['account_update2', AccountUpdate2Operation] | ['account_witness_vote', AccountWitnessVoteOperation] | ['account_witness_proxy', AccountWitnessProxyOperation] | ['convert', ConvertOperation] | ['collateralized_convert', CollateralizedConvertOperation] | ['custom', CustomOperation] | ['custom_json', CustomJsonOperation] | ['claim_account', ClaimAccountOperation] | ['create_claimed_account', CreateClaimedAccountOperation] | ['claim_reward_balance', ClaimRewardBalanceOperation] | ['delegate_vesting_shares', DelegateVestingSharesOperation] | ['delete_comment', DeleteCommentOperation] | ['comment_options', CommentOptionsOperation] | ['set_withdraw_vesting_route', SetWithdrawVestingRouteOperation] | ['witness_update', WitnessUpdateOperation] | ['witness_set_properties', WitnessSetPropertiesOperation] | ['decline_voting_rights', DeclineVotingRightsOperation] | ['reset_account', ResetAccountOperation] | ['set_reset_account', SetResetAccountOperation] | ['transfer_to_savings', TransferToSavingsOperation] | ['transfer_from_savings', TransferFromSavingsOperation] | ['cancel_transfer_from_savings', CancelTransferFromSavingsOperation] | ['limit_order_create', LimitOrderCreateOperation] | ['limit_order_create2', LimitOrderCreate2Operation] | ['limit_order_cancel', LimitOrderCancelOperation] | ['feed_publish', FeedPublishOperation] | ['escrow_transfer', EscrowTransferOperation] | ['escrow_dispute', EscrowDisputeOperation] | ['escrow_release', EscrowReleaseOperation] | ['escrow_approve', EscrowApproveOperation] | ['recover_account', RecoverAccountOperation] | ['request_account_recovery', RequestAccountRecoveryOperation] | ['change_recovery_account', ChangeRecoveryAccountOperation] | ['recurrent_transfer', RecurrentTransferOperation] | ['create_proposal', CreateProposalOperation] | ['update_proposal', UpdateProposalOperation] | ['update_proposal_votes', UpdateProposalVotesOperation] | ['remove_proposal', RemoveProposalOperation];
568
+ type OperationName = Operation[0];
569
+ type OperationBody<O extends OperationName> = Extract<Operation, [O, any]>[1];
570
+ type WitnessSetPropertiesParams = WitnessProps$1;
571
+ type Extension = [] | [string, unknown] | [number, unknown];
572
+ interface TransactionType {
573
+ expiration: string;
574
+ extensions: Extension[];
575
+ operations: [OperationName, OperationBody<OperationName>][];
576
+ ref_block_num: number;
577
+ ref_block_prefix: number;
578
+ signatures: string[];
579
+ }
580
+ interface BroadcastError {
581
+ id: number;
582
+ jsonrpc: string;
583
+ error: {
584
+ code: number;
585
+ message: string;
586
+ data?: any;
587
+ };
588
+ }
589
+ type CallResponse<T = any> = {
590
+ id: number;
591
+ jsonrpc: string;
592
+ result: T;
593
+ } | BroadcastError;
594
+ interface BroadcastResult {
595
+ tx_id: string;
596
+ status: 'unknown' | 'within_irreversible_block' | 'expired_irreversible' | 'too_old';
597
+ }
598
+ interface DigestData {
599
+ digest: Uint8Array;
600
+ txId: string;
601
+ }
602
+ interface TransactionStatus {
603
+ status: 'unknown' | 'within_mempool' | 'within_reversible_block' | 'within_irreversible_block' | 'expired_reversible' | 'expired_irreversible' | 'too_old';
604
+ }
605
+
606
+ interface TransactionOptions {
607
+ transaction?: TransactionType | Transaction;
608
+ /**
609
+ * Transaction expiration in milliseconds (ms) - max 86400000 (24 hours)
610
+ * @default 60_000
611
+ */
612
+ expiration?: number;
613
+ }
614
+ declare class Transaction {
615
+ transaction?: TransactionType;
616
+ expiration: number;
617
+ private txId?;
618
+ constructor(options?: TransactionOptions);
619
+ /**
620
+ * Adds an operation to the transaction. If no transaction exists, creates one first.
621
+ * @template O Operation name type for type safety
622
+ * @param operationName The name/type of the operation to add (e.g., 'transfer', 'vote', 'comment')
623
+ * @param operationBody The operation data/body for the specified operation type
624
+ * @returns Promise that resolves when the operation is added
625
+ * @throws Error if transaction creation fails or global properties cannot be retrieved
626
+ */
627
+ addOperation<O extends OperationName>(operationName: O, operationBody: OperationBody<O>): Promise<void>;
628
+ /**
629
+ * Signs the transaction with the provided key(s), supporting both single and multi-signature transactions.
630
+ * For multi-signature, you can sign with all keys at once or sign individually by calling this method multiple times.
631
+ * @param keys Single PrivateKey or array of PrivateKeys to sign the transaction with
632
+ * @returns The signed transaction
633
+ * @throws Error if no transaction exists to sign
634
+ */
635
+ sign(keys: PrivateKey | PrivateKey[]): TransactionType;
636
+ /**
637
+ * Broadcasts the signed transaction to the Hive network.
638
+ * Automatically handles retries and duplicate transaction detection.
639
+ * @param checkStatus By default (false) the transaction is not guaranteed to be included in a block.
640
+ * For example the transaction can expire while waiting in mempool.
641
+ * If you pass true here, the function will wait for the transaction to be either included or dropped
642
+ * before returning a result.
643
+ * @returns Promise resolving to broadcast result
644
+ * @throws Error if no transaction exists or transaction is not signed or transaction got rejected
645
+ */
646
+ broadcast(checkStatus?: boolean): Promise<BroadcastResult>;
647
+ /**
648
+ * Returns the transaction digest containing the transaction ID and hash.
649
+ * The digest can be used to verify signatures and for transaction identification.
650
+ * @returns DigestData containing transaction ID and hash
651
+ * @throws Error if no transaction exists
652
+ */
653
+ digest(): DigestData;
654
+ /**
655
+ * Adds a signature to an already created transaction. Useful when signing with external tools.
656
+ * Multiple signatures can be added one at a time for multi-signature transactions.
657
+ * @param signature The signature string in hex format (must be exactly 130 characters)
658
+ * @returns The transaction with the added signature
659
+ * @throws Error if no transaction exists or signature format is invalid
660
+ */
661
+ addSignature(signature: string): TransactionType;
662
+ /** Get status of this transaction. Usually called internally after broadcasting. */
663
+ checkStatus(): Promise<TransactionStatus>;
664
+ /**
665
+ * Creates the transaction structure and initializes it with blockchain data.
666
+ * Retrieves current head block information and sets up reference block data.
667
+ * @private
668
+ * @param expiration Transaction expiration in milliseconds
669
+ */
670
+ private createTransaction;
671
+ }
672
+
673
+ /**
674
+ * REST API method identifiers for Hive blockchain APIs.
675
+ * Used by callREST() to route requests to the correct API path prefix.
676
+ */
677
+ type APIMethods = 'balance' | 'hafah' | 'hafbe' | 'hivemind' | 'hivesense' | 'reputation' | 'nft-tracker' | 'hafsql' | 'status';
678
+
679
+ /**
680
+ * Makes API calls to Hive blockchain nodes with automatic retry and failover support.
681
+ * Uses per-request retry counters, node health tracking, jitter between retries,
682
+ * and HTTP status awareness (429 rate limiting, 503).
683
+ *
684
+ * If the current node fails, it will automatically try the next healthy node.
685
+ * When all nodes have been tried, wraps around to give earlier nodes another chance
686
+ * until the full retry budget (config.retry) is exhausted.
687
+ * RPCErrors (valid blockchain rejections) are never retried.
688
+ *
689
+ * @param method - The API method name (e.g., 'condenser_api.get_accounts')
690
+ * @param params - Parameters for the API method as array or object
691
+ * @param timeout - Request timeout in milliseconds (default: config.timeout)
692
+ * @param retry - Maximum number of retry attempts (default: config.retry)
693
+ * @returns Promise resolving to the API response
694
+ * @throws {RPCError} On blockchain-level errors (bad params, missing authority, etc.)
695
+ * @throws {Error} If all retry attempts fail
696
+ *
697
+ * @example
698
+ * ```typescript
699
+ * import { callRPC } from 'hive-tx'
700
+ *
701
+ * // Get account information
702
+ * const accounts = await callRPC('condenser_api.get_accounts', [['alice']])
703
+ *
704
+ * // Custom timeout and retry settings
705
+ * const data = await callRPC('condenser_api.get_content', ['alice', 'test-post'], 10_000, 5)
706
+ * ```
707
+ */
708
+ declare const callRPC: <T = any>(method: string, params?: any[] | object, timeout?: number, retry?: number, signal?: AbortSignal) => Promise<T>;
709
+ /**
710
+ * Broadcast-safe RPC call. Only retries on pre-connection errors where the
711
+ * request definitively never reached the server (ECONNREFUSED, ENOTFOUND, etc.).
712
+ * On timeouts, HTTP errors, or any ambiguous failure, throws immediately to
713
+ * prevent double-broadcasting transactions.
714
+ *
715
+ * Tries each node once (no wrap-around) since broadcast retries are dangerous.
716
+ *
717
+ * @internal Used by Transaction.broadcast()
718
+ */
719
+ declare const callRPCBroadcast: <T = any>(method: string, params?: any[] | object, timeout?: number, signal?: AbortSignal) => Promise<T>;
720
+ /**
721
+ * Makes REST API calls to Hive blockchain REST endpoints with automatic retry and failover support.
722
+ * Uses per-request retry counters, node health tracking, and timeout support.
723
+ * Wraps around the node list to honor the full retry budget.
724
+ *
725
+ * @template Api - The REST API method type (e.g., 'balance', 'hafah', 'hivemind', etc.)
726
+ * @template P - The endpoint path type for the specified API
727
+ *
728
+ * @param api - The REST API method name to call
729
+ * @param endpoint - The specific endpoint path within the API
730
+ * @param params - Optional parameters for path and query string replacement
731
+ * @param timeout - Request timeout in milliseconds (default: config.timeout)
732
+ * @param retry - Number of retry attempts before throwing an error (default: config.retry)
733
+ *
734
+ * @returns Promise resolving to the API response data with proper typing
735
+ * @throws Error if all retry attempts fail
736
+ *
737
+ * @example
738
+ * ```typescript
739
+ * import { callREST } from 'hive-tx'
740
+ *
741
+ * // Get account balance
742
+ * const balance = await callREST('balance', '/accounts/{account-name}/balances', { "account-name": 'alice' })
743
+ *
744
+ * // Custom timeout and retry settings
745
+ * const data = await callREST('status', '/status', undefined, 10_000, 3)
746
+ * ```
747
+ */
748
+ declare function callREST(api: APIMethods, endpoint: string, params?: Record<string, any>, timeout?: number, retry?: number, signal?: AbortSignal): Promise<any>;
749
+ /**
750
+ * Make a JSONRPC call with quorum. The method will cross-check the result
751
+ * with `quorum` number of nodes before returning the result.
752
+ * @param method - The API method name (e.g., 'condenser_api.get_accounts')
753
+ * @param params - Parameters for the API method as array or object
754
+ * @param quorum - Default: 2 (recommended)
755
+ */
756
+ declare const callWithQuorum: <T = any>(method: string, params?: any[] | object, quorum?: number, signal?: AbortSignal) => Promise<T>;
757
+
758
+ /**
759
+ * Unified configuration for Hive blockchain connectivity.
760
+ * This is the single source of truth for node endpoints, timeouts, and chain settings.
761
+ * Mutate this object directly or use ConfigManager.setHiveNodes() for validated updates.
762
+ */
763
+ declare const config: {
764
+ /**
765
+ * Array of Hive API node endpoints for load balancing and failover.
766
+ */
767
+ nodes: string[];
768
+ /**
769
+ * Array of Hive API node endpoints that support REST APIs.
770
+ * Note: Without the trailing /
771
+ */
772
+ restNodes: string[];
773
+ /**
774
+ * The Hive blockchain chain ID for transaction signing and verification.
775
+ */
776
+ chain_id: string;
777
+ /**
778
+ * Address prefix used for public key formatting (STM for mainnet).
779
+ */
780
+ address_prefix: string;
781
+ /**
782
+ * Timeout in milliseconds for individual API calls.
783
+ */
784
+ timeout: number;
785
+ /**
786
+ * Number of retry attempts for failed API calls before throwing an error.
787
+ */
788
+ retry: number;
789
+ };
790
+
791
+ type Memo = {
792
+ /**
793
+ * Encrypts a memo for secure private messaging
794
+ */
795
+ encode(privateKey: string | PrivateKey, publicKey: string | PublicKey, memo: string, testNonce?: any): string;
796
+ /**
797
+ * Decrypts a memo message
798
+ */
799
+ decode(privateKey: string | PrivateKey, memo: string): string;
800
+ };
801
+ /**
802
+ * Memo utilities for encrypting and decrypting private messages between Hive users.
803
+ * Uses AES encryption with ECDH key exchange for secure communication.
804
+ *
805
+ * Messages must start with '#' to be encrypted/decrypted.
806
+ * Plain text messages (without '#') are returned unchanged.
807
+ *
808
+ * @example
809
+ * ```typescript
810
+ * import { Memo, PrivateKey, PublicKey } from 'hive-tx'
811
+ *
812
+ * // Encrypt a message
813
+ * const encrypted = Memo.encode(senderPrivateKey, recipientPublicKey, '#Hello World')
814
+ *
815
+ * // Decrypt a message
816
+ * const decrypted = Memo.decode(recipientPrivateKey, encrypted)
817
+ * console.log(decrypted) // '#Hello World'
818
+ * ```
819
+ */
820
+ declare const Memo: {
821
+ decode: (privateKey: string | PrivateKey, memo: string) => string;
822
+ encode: (privateKey: string | PrivateKey, publicKey: string | PublicKey, memo: string, testNonce?: any) => string;
823
+ };
824
+
825
+ interface WitnessProps {
826
+ account_creation_fee?: string;
827
+ account_subsidy_budget?: number;
828
+ account_subsidy_decay?: number;
829
+ key: PublicKey | string;
830
+ maximum_block_size?: number;
831
+ new_signing_key?: PublicKey | string | null;
832
+ hbd_exchange_rate?: {
833
+ base: string;
834
+ quote: string;
835
+ };
836
+ hbd_interest_rate?: number;
837
+ url?: string;
838
+ }
839
+ /** Return null for a valid username */
840
+ declare const validateUsername: (username: string) => null | string;
841
+ declare const operations: {
842
+ vote: number;
843
+ comment: number;
844
+ transfer: number;
845
+ transfer_to_vesting: number;
846
+ withdraw_vesting: number;
847
+ limit_order_create: number;
848
+ limit_order_cancel: number;
849
+ feed_publish: number;
850
+ convert: number;
851
+ account_create: number;
852
+ account_update: number;
853
+ witness_update: number;
854
+ account_witness_vote: number;
855
+ account_witness_proxy: number;
856
+ pow: number;
857
+ custom: number;
858
+ report_over_production: number;
859
+ delete_comment: number;
860
+ custom_json: number;
861
+ comment_options: number;
862
+ set_withdraw_vesting_route: number;
863
+ limit_order_create2: number;
864
+ claim_account: number;
865
+ create_claimed_account: number;
866
+ request_account_recovery: number;
867
+ recover_account: number;
868
+ change_recovery_account: number;
869
+ escrow_transfer: number;
870
+ escrow_dispute: number;
871
+ escrow_release: number;
872
+ pow2: number;
873
+ escrow_approve: number;
874
+ transfer_to_savings: number;
875
+ transfer_from_savings: number;
876
+ cancel_transfer_from_savings: number;
877
+ custom_binary: number;
878
+ decline_voting_rights: number;
879
+ reset_account: number;
880
+ set_reset_account: number;
881
+ claim_reward_balance: number;
882
+ delegate_vesting_shares: number;
883
+ account_create_with_delegation: number;
884
+ witness_set_properties: number;
885
+ account_update2: number;
886
+ create_proposal: number;
887
+ update_proposal_votes: number;
888
+ remove_proposal: number;
889
+ update_proposal: number;
890
+ collateralized_convert: number;
891
+ recurrent_transfer: number;
892
+ fill_convert_request: number;
893
+ author_reward: number;
894
+ curation_reward: number;
895
+ comment_reward: number;
896
+ liquidity_reward: number;
897
+ interest: number;
898
+ fill_vesting_withdraw: number;
899
+ fill_order: number;
900
+ shutdown_witness: number;
901
+ fill_transfer_from_savings: number;
902
+ hardfork: number;
903
+ comment_payout_update: number;
904
+ return_vesting_delegation: number;
905
+ comment_benefactor_reward: number;
906
+ producer_reward: number;
907
+ clear_null_account_balance: number;
908
+ proposal_pay: number;
909
+ sps_fund: number;
910
+ hardfork_hive: number;
911
+ hardfork_hive_restore: number;
912
+ delayed_voting: number;
913
+ consolidate_treasury_balance: number;
914
+ effective_comment_vote: number;
915
+ ineffective_delete_comment: number;
916
+ sps_convert: number;
917
+ expired_account_notification: number;
918
+ changed_recovery_account: number;
919
+ transfer_to_vesting_completed: number;
920
+ pow_reward: number;
921
+ vesting_shares_split: number;
922
+ account_created: number;
923
+ fill_collateralized_convert_request: number;
924
+ system_warning: number;
925
+ fill_recurrent_transfer: number;
926
+ failed_recurrent_transfer: number;
927
+ limit_order_cancelled: number;
928
+ producer_missed: number;
929
+ proposal_fee: number;
930
+ collateralized_convert_immediate_conversion: number;
931
+ escrow_approved: number;
932
+ escrow_rejected: number;
933
+ proxy_cleared: number;
934
+ declined_voting_rights: number;
935
+ };
936
+ /**
937
+ * Make bitmask filter to be used with get_account_history call
938
+ */
939
+ declare const makeBitMaskFilter: (allowedOperations: number[]) => [string | null, string | null];
940
+ declare const buildWitnessSetProperties: (owner: string, props: WitnessProps) => ["witness_set_properties", {
941
+ extensions: never[];
942
+ owner: string;
943
+ props: any;
944
+ }];
945
+
946
+ type utils_WitnessProps = WitnessProps;
947
+ declare const utils_buildWitnessSetProperties: typeof buildWitnessSetProperties;
948
+ declare const utils_makeBitMaskFilter: typeof makeBitMaskFilter;
949
+ declare const utils_operations: typeof operations;
950
+ declare const utils_validateUsername: typeof validateUsername;
951
+ declare namespace utils {
952
+ export { type utils_WitnessProps as WitnessProps, utils_buildWitnessSetProperties as buildWitnessSetProperties, utils_makeBitMaskFilter as makeBitMaskFilter, utils_operations as operations, utils_validateUsername as validateUsername };
953
+ }
954
+
955
+ export { type LimitOrderCreate2Operation as $, type Authority as A, type BroadcastResult as B, type CustomJsonOperation as C, type CustomOperation as D, type ClaimAccountOperation as E, type CreateClaimedAccountOperation as F, type ClaimRewardBalanceOperation as G, type DelegateVestingSharesOperation as H, type DeleteCommentOperation as I, type CommentOptionsOperation as J, type SetWithdrawVestingRouteOperation as K, type WitnessUpdateOperation as L, Memo as M, type WitnessSetPropertiesOperation as N, type Operation as O, PrivateKey as P, type DeclineVotingRightsOperation as Q, type ResetAccountOperation as R, Signature as S, Transaction as T, type SetResetAccountOperation as U, type VoteOperation as V, type WitnessProps$1 as W, type TransferToSavingsOperation as X, type TransferFromSavingsOperation as Y, type CancelTransferFromSavingsOperation as Z, type LimitOrderCreateOperation as _, PublicKey as a, type LimitOrderCancelOperation as a0, type FeedPublishOperation as a1, type EscrowTransferOperation as a2, type EscrowDisputeOperation as a3, type EscrowReleaseOperation as a4, type EscrowApproveOperation as a5, type RecoverAccountOperation as a6, type RequestAccountRecoveryOperation as a7, type ChangeRecoveryAccountOperation as a8, type RecurrentTransferOperation as a9, type CreateProposalOperation as aa, type UpdateProposalOperation as ab, type UpdateProposalVotesOperation as ac, type RemoveProposalOperation as ad, type WitnessSetPropertiesParams as ae, type Extension as af, type TransactionType as ag, type BroadcastError as ah, type CallResponse as ai, type DigestData as aj, type TransactionStatus as ak, type OperationName as b, config as c, callRPC as d, callRPCBroadcast as e, callREST as f, callWithQuorum as g, type OperationBody as h, type AssetSymbol as i, type AccountCreateOperation as j, type Beneficiary as k, type Price as l, type ChainProperties as m, type CommentOperation as n, operations as o, type TransferOperation as p, type TransferToVestingOperation as q, type WithdrawVestingOperation as r, type AccountCreateWithDelegationOperation as s, type AccountUpdateOperation as t, utils as u, type AccountUpdate2Operation as v, type AccountWitnessVoteOperation as w, type AccountWitnessProxyOperation as x, type ConvertOperation as y, type CollateralizedConvertOperation as z };