-
Notifications
You must be signed in to change notification settings - Fork 8
/
signTransaction.ts
89 lines (76 loc) · 2.51 KB
/
signTransaction.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type { IdentifierString, WalletAccount } from '@wallet-standard/base';
/** Name of the feature. */
export const BitcoinSignTransaction = 'bitcoin:signTransaction';
/**
* `bitcoin:signTransaction` is a {@link "@wallet-standard/base".Wallet.features | feature} that may be implemented by a
* {@link "@wallet-standard/base".Wallet} to allow the app to request to sign transactions with the specified
* {@link "@wallet-standard/base".Wallet.accounts}.
*
* @group SignTransaction
*/
export type BitcoinSignTransactionFeature = {
/** Name of the feature. */
readonly [BitcoinSignTransaction]: {
/** Version of the feature implemented by the Wallet. */
readonly version: BitcoinSignTransactionVersion;
/** Method to call to use the feature. */
readonly signTransaction: BitcoinSignTransactionMethod;
};
};
/**
* Version of the {@link BitcoinSignTransactionFeature} implemented by a {@link "@wallet-standard/base".Wallet}.
*
* @group SignTransaction
*/
export type BitcoinSignTransactionVersion = '1.0.0';
/**
* Method to call to use the {@link BitcoinSignTransactionFeature}.
*
* @group SignTransaction
*/
export type BitcoinSignTransactionMethod = (
...inputs: readonly BitcoinSignTransactionInput[]
) => Promise<readonly BitcoinSignTransactionOutput[]>;
/**
* Input for the {@link BitcoinSignTransactionMethod}.
*
* @group SignTransaction
*/
export interface BitcoinSignTransactionInput {
/** Partially Signed Bitcoin Transaction (PSBT), as raw bytes. */
readonly psbt: Uint8Array;
/** Transaction inputs to sign. */
readonly inputsToSign: InputToSign[];
/** Chain to use. */
readonly chain?: IdentifierString;
}
/**
* Transaction input to be signed with the specified {@link "@wallet-standard/base".WalletAccount | account}.
*
* @group SignTransaction
* */
export interface InputToSign {
/** Account to use. */
readonly account: WalletAccount;
/** List of input indexes that should be signed by the account. */
readonly signingIndexes: number[];
/** A SIGHASH flag. */
readonly sigHash?: BitcoinSigHashFlag;
}
/**
* Output of the {@link BitcoinSignTransactionMethod}.
*
* @group SignTransaction
*/
export interface BitcoinSignTransactionOutput {
/** Signed Partially Signed Bitcoin Transaction (PSBT), as raw bytes. */
readonly signedPsbt: Uint8Array;
}
/** SIGHASH flag. */
export type BitcoinSigHashFlag =
| 'ALL'
| 'NONE'
| 'SINGLE'
| 'ALL|ANYONECANPAY'
| 'NONE|ANYONECANPAY'
| 'SINGLE|ANYONECANPAY';