quorum-sdk 0.1.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 +134 -0
- package/dist/index.d.mts +250 -0
- package/dist/index.d.ts +250 -0
- package/dist/index.js +257 -0
- package/dist/index.mjs +231 -0
- package/package.json +36 -0
- package/src/index.ts +413 -0
- package/tsconfig.json +16 -0
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# @agent-multisig/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the Agent Multisig Coordination API.
|
|
4
|
+
|
|
5
|
+
Enables AI agents to participate in multi-signature Bitcoin transactions.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @agent-multisig/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { AgentMultisig } from '@agent-multisig/sdk';
|
|
17
|
+
|
|
18
|
+
const client = new AgentMultisig({
|
|
19
|
+
apiUrl: 'https://agent-multisig-api-production.up.railway.app',
|
|
20
|
+
apiKey: 'your-api-key' // optional
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// Quick setup: register agents and create multisig in one call
|
|
24
|
+
const { multisig, agents } = await client.quickSetup({
|
|
25
|
+
name: 'AI Treasury',
|
|
26
|
+
threshold: 2,
|
|
27
|
+
signers: [
|
|
28
|
+
{ name: 'TreasuryBot', provider: 'aibtc', publicKey: '...' },
|
|
29
|
+
{ name: 'AuditBot', provider: 'aibtc', publicKey: '...' },
|
|
30
|
+
{ name: 'BackupBot', provider: 'aibtc', publicKey: '...' },
|
|
31
|
+
],
|
|
32
|
+
network: 'mainnet'
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
console.log('Fund this address:', multisig.address);
|
|
36
|
+
// => bc1p6f4vmxvwnpgrgmmc4653u28jxlrf3enh0qwcev6safpcfy4y8gdqfcnjf6
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Creating a Spend Proposal
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
// Create a proposal to spend from the multisig
|
|
43
|
+
const proposal = await client.createProposal({
|
|
44
|
+
multisigId: multisig.id,
|
|
45
|
+
to: 'bc1qpzlw29z50cz7ysjpsaqggtscya3p6ggehnsp2g',
|
|
46
|
+
amount: 10000 // satoshis
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
console.log('PSBT to sign:', proposal.psbtHex);
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Signing
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Each agent signs the proposal
|
|
56
|
+
await client.signProposal({
|
|
57
|
+
proposalId: proposal.id,
|
|
58
|
+
agentId: agents[0].id,
|
|
59
|
+
signature: 'schnorr_signature_hex...'
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await client.signProposal({
|
|
63
|
+
proposalId: proposal.id,
|
|
64
|
+
agentId: agents[1].id,
|
|
65
|
+
signature: 'schnorr_signature_hex...'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Once threshold is met, broadcast
|
|
69
|
+
const { txid } = await client.broadcastProposal(proposal.id);
|
|
70
|
+
console.log('Transaction broadcast:', txid);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Waiting for Confirmation
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
// Wait for the proposal to be confirmed on-chain
|
|
77
|
+
const confirmed = await client.waitForProposal(proposal.id, 'confirmed', {
|
|
78
|
+
timeoutMs: 600000, // 10 minutes
|
|
79
|
+
pollIntervalMs: 10000 // check every 10 seconds
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
console.log('Confirmed in txid:', confirmed.txid);
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Real-World Example
|
|
86
|
+
|
|
87
|
+
This SDK was used to execute a real 2-of-3 multisig transaction on Bitcoin mainnet:
|
|
88
|
+
|
|
89
|
+
**Funding TX:** [3222492b...](https://mempool.space/tx/3222492b560eb8b6898746ea11f3b4eed1dbf5fff21df75b581eea701edd0222)
|
|
90
|
+
**Spend TX:** [8b371247...](https://mempool.space/tx/8b3712476f38b1563ce1b7b8f521ea4ee2fec1fdd249f535f1d5f5f0125040d4)
|
|
91
|
+
|
|
92
|
+
20,000 sats → 2-of-3 Taproot multisig → Signed by 2 agents → Confirmed in block 937432.
|
|
93
|
+
|
|
94
|
+
## API Reference
|
|
95
|
+
|
|
96
|
+
### `new AgentMultisig(config)`
|
|
97
|
+
|
|
98
|
+
Create a new client instance.
|
|
99
|
+
|
|
100
|
+
| Option | Type | Description |
|
|
101
|
+
|--------|------|-------------|
|
|
102
|
+
| `apiUrl` | `string` | API base URL |
|
|
103
|
+
| `apiKey` | `string?` | Optional API key |
|
|
104
|
+
| `timeout` | `number?` | Request timeout in ms (default: 30000) |
|
|
105
|
+
|
|
106
|
+
### Agents
|
|
107
|
+
|
|
108
|
+
- `registerAgent(input)` - Register a new agent
|
|
109
|
+
- `getAgent(agentId)` - Get agent by ID
|
|
110
|
+
- `listAgents()` - List all agents
|
|
111
|
+
|
|
112
|
+
### Multisigs
|
|
113
|
+
|
|
114
|
+
- `createMultisig(input)` - Create a new multisig
|
|
115
|
+
- `getMultisig(multisigId)` - Get multisig by ID
|
|
116
|
+
- `listMultisigs()` - List all multisigs
|
|
117
|
+
- `getMultisigBalance(multisigId)` - Get balance and UTXOs
|
|
118
|
+
|
|
119
|
+
### Proposals
|
|
120
|
+
|
|
121
|
+
- `createProposal(input)` - Create a spend proposal
|
|
122
|
+
- `getProposal(proposalId)` - Get proposal by ID
|
|
123
|
+
- `listProposals(multisigId?)` - List proposals
|
|
124
|
+
- `signProposal(input)` - Submit a signature
|
|
125
|
+
- `broadcastProposal(proposalId)` - Broadcast when ready
|
|
126
|
+
|
|
127
|
+
### Convenience
|
|
128
|
+
|
|
129
|
+
- `quickSetup(input)` - Register agents + create multisig in one call
|
|
130
|
+
- `waitForProposal(id, status, options)` - Poll until status reached
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Multisig SDK
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the Agent Multisig Coordination API.
|
|
5
|
+
* Enables AI agents to participate in multi-signature Bitcoin transactions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentMultisig } from '@agent-multisig/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const client = new AgentMultisig({
|
|
12
|
+
* apiUrl: 'https://agent-multisig-api-production.up.railway.app',
|
|
13
|
+
* apiKey: 'your-api-key'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Register an agent
|
|
17
|
+
* const agent = await client.registerAgent({
|
|
18
|
+
* name: 'TreasuryBot',
|
|
19
|
+
* provider: 'aibtc',
|
|
20
|
+
* publicKey: '9350761ae700acd872510de161bca0b90b78ddc007936674b318be8a50c531b5'
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Create a 2-of-3 multisig
|
|
24
|
+
* const multisig = await client.createMultisig({
|
|
25
|
+
* name: 'AI Treasury',
|
|
26
|
+
* threshold: 2,
|
|
27
|
+
* agents: [agent1.id, agent2.id, agent3.id],
|
|
28
|
+
* network: 'mainnet'
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Create a spend proposal
|
|
32
|
+
* const proposal = await client.createProposal({
|
|
33
|
+
* multisigId: multisig.id,
|
|
34
|
+
* to: 'bc1q...',
|
|
35
|
+
* amount: 10000
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Sign the proposal
|
|
39
|
+
* await client.signProposal(proposal.id, agent.id, signature);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
interface AgentMultisigConfig {
|
|
43
|
+
apiUrl: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
timeout?: number;
|
|
46
|
+
}
|
|
47
|
+
interface Agent {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
provider: 'aibtc' | 'agentkit' | 'crossmint' | 'clawcash' | 'bankr' | 'custom';
|
|
51
|
+
publicKey: string;
|
|
52
|
+
chain: 'bitcoin' | 'stacks' | 'evm' | 'solana';
|
|
53
|
+
createdAt: string;
|
|
54
|
+
}
|
|
55
|
+
interface RegisterAgentInput {
|
|
56
|
+
name: string;
|
|
57
|
+
provider: Agent['provider'];
|
|
58
|
+
publicKey: string;
|
|
59
|
+
chain?: Agent['chain'];
|
|
60
|
+
webhookUrl?: string;
|
|
61
|
+
metadata?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
interface Multisig {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
address: string;
|
|
67
|
+
threshold: number;
|
|
68
|
+
totalSigners: number;
|
|
69
|
+
agents: string[];
|
|
70
|
+
network: 'mainnet' | 'testnet' | 'signet';
|
|
71
|
+
chain: 'bitcoin' | 'stacks' | 'evm' | 'solana';
|
|
72
|
+
scriptHex?: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
}
|
|
75
|
+
interface CreateMultisigInput {
|
|
76
|
+
name: string;
|
|
77
|
+
threshold: number;
|
|
78
|
+
agents: string[];
|
|
79
|
+
network?: 'mainnet' | 'testnet' | 'signet';
|
|
80
|
+
chain?: Multisig['chain'];
|
|
81
|
+
}
|
|
82
|
+
interface Proposal {
|
|
83
|
+
id: string;
|
|
84
|
+
multisigId: string;
|
|
85
|
+
type: 'spend' | 'custom';
|
|
86
|
+
status: 'pending' | 'ready' | 'broadcast' | 'confirmed' | 'failed';
|
|
87
|
+
to?: string;
|
|
88
|
+
amount?: number;
|
|
89
|
+
psbtHex?: string;
|
|
90
|
+
signatures: ProposalSignature[];
|
|
91
|
+
txid?: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
expiresAt?: string;
|
|
94
|
+
}
|
|
95
|
+
interface ProposalSignature {
|
|
96
|
+
agentId: string;
|
|
97
|
+
signature: string;
|
|
98
|
+
signedAt: string;
|
|
99
|
+
}
|
|
100
|
+
interface CreateProposalInput {
|
|
101
|
+
multisigId: string;
|
|
102
|
+
to: string;
|
|
103
|
+
amount: number;
|
|
104
|
+
memo?: string;
|
|
105
|
+
}
|
|
106
|
+
interface SignProposalInput {
|
|
107
|
+
proposalId: string;
|
|
108
|
+
agentId: string;
|
|
109
|
+
signature: string;
|
|
110
|
+
}
|
|
111
|
+
declare class AgentMultisigError extends Error {
|
|
112
|
+
statusCode?: number | undefined;
|
|
113
|
+
code?: string | undefined;
|
|
114
|
+
constructor(message: string, statusCode?: number | undefined, code?: string | undefined);
|
|
115
|
+
}
|
|
116
|
+
declare class AgentMultisig {
|
|
117
|
+
private apiUrl;
|
|
118
|
+
private apiKey?;
|
|
119
|
+
private timeout;
|
|
120
|
+
constructor(config: AgentMultisigConfig);
|
|
121
|
+
private request;
|
|
122
|
+
health(): Promise<{
|
|
123
|
+
status: string;
|
|
124
|
+
version: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Register a new agent with the coordination API.
|
|
128
|
+
*/
|
|
129
|
+
registerAgent(input: RegisterAgentInput): Promise<Agent>;
|
|
130
|
+
/**
|
|
131
|
+
* Get an agent by ID.
|
|
132
|
+
*/
|
|
133
|
+
getAgent(agentId: string): Promise<Agent>;
|
|
134
|
+
/**
|
|
135
|
+
* List all registered agents.
|
|
136
|
+
*/
|
|
137
|
+
listAgents(): Promise<Agent[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a new multisig wallet.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const multisig = await client.createMultisig({
|
|
144
|
+
* name: 'AI Treasury',
|
|
145
|
+
* threshold: 2,
|
|
146
|
+
* agents: ['agent_abc', 'agent_def', 'agent_ghi'],
|
|
147
|
+
* network: 'mainnet'
|
|
148
|
+
* });
|
|
149
|
+
* console.log('Fund this address:', multisig.address);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
createMultisig(input: CreateMultisigInput): Promise<Multisig>;
|
|
153
|
+
/**
|
|
154
|
+
* Get a multisig by ID.
|
|
155
|
+
*/
|
|
156
|
+
getMultisig(multisigId: string): Promise<Multisig>;
|
|
157
|
+
/**
|
|
158
|
+
* List all multisigs.
|
|
159
|
+
*/
|
|
160
|
+
listMultisigs(): Promise<Multisig[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Get the balance of a multisig wallet.
|
|
163
|
+
*/
|
|
164
|
+
getMultisigBalance(multisigId: string): Promise<{
|
|
165
|
+
confirmed: number;
|
|
166
|
+
unconfirmed: number;
|
|
167
|
+
utxos: Array<{
|
|
168
|
+
txid: string;
|
|
169
|
+
vout: number;
|
|
170
|
+
value: number;
|
|
171
|
+
}>;
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* Create a spend proposal for a multisig.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const proposal = await client.createProposal({
|
|
179
|
+
* multisigId: 'msig_xyz',
|
|
180
|
+
* to: 'bc1qpzlw29z50cz7ysjpsaqggtscya3p6ggehnsp2g',
|
|
181
|
+
* amount: 10000 // satoshis
|
|
182
|
+
* });
|
|
183
|
+
* console.log('PSBT to sign:', proposal.psbtHex);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
createProposal(input: CreateProposalInput): Promise<Proposal>;
|
|
187
|
+
/**
|
|
188
|
+
* Get a proposal by ID.
|
|
189
|
+
*/
|
|
190
|
+
getProposal(proposalId: string): Promise<Proposal>;
|
|
191
|
+
/**
|
|
192
|
+
* List proposals, optionally filtered by multisig.
|
|
193
|
+
*/
|
|
194
|
+
listProposals(multisigId?: string): Promise<Proposal[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Sign a proposal with an agent's key.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Agent signs the PSBT and submits signature
|
|
201
|
+
* const signature = await myWallet.signPsbt(proposal.psbtHex);
|
|
202
|
+
* await client.signProposal({
|
|
203
|
+
* proposalId: proposal.id,
|
|
204
|
+
* agentId: myAgent.id,
|
|
205
|
+
* signature: signature
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
signProposal(input: SignProposalInput): Promise<Proposal>;
|
|
210
|
+
/**
|
|
211
|
+
* Broadcast a fully-signed proposal.
|
|
212
|
+
*/
|
|
213
|
+
broadcastProposal(proposalId: string): Promise<{
|
|
214
|
+
txid: string;
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Create a multisig and register agents in one call.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const { multisig, agents } = await client.quickSetup({
|
|
222
|
+
* name: 'Quick Treasury',
|
|
223
|
+
* threshold: 2,
|
|
224
|
+
* signers: [
|
|
225
|
+
* { name: 'Bot1', provider: 'aibtc', publicKey: '...' },
|
|
226
|
+
* { name: 'Bot2', provider: 'aibtc', publicKey: '...' },
|
|
227
|
+
* { name: 'Bot3', provider: 'aibtc', publicKey: '...' },
|
|
228
|
+
* ]
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
quickSetup(input: {
|
|
233
|
+
name: string;
|
|
234
|
+
threshold: number;
|
|
235
|
+
signers: RegisterAgentInput[];
|
|
236
|
+
network?: 'mainnet' | 'testnet' | 'signet';
|
|
237
|
+
}): Promise<{
|
|
238
|
+
multisig: Multisig;
|
|
239
|
+
agents: Agent[];
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* Wait for a proposal to reach a target status.
|
|
243
|
+
*/
|
|
244
|
+
waitForProposal(proposalId: string, targetStatus: Proposal['status'], options?: {
|
|
245
|
+
timeoutMs?: number;
|
|
246
|
+
pollIntervalMs?: number;
|
|
247
|
+
}): Promise<Proposal>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { type Agent, AgentMultisig, type AgentMultisigConfig, AgentMultisigError, type CreateMultisigInput, type CreateProposalInput, type Multisig, type Proposal, type ProposalSignature, type RegisterAgentInput, type SignProposalInput, AgentMultisig as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Multisig SDK
|
|
3
|
+
*
|
|
4
|
+
* TypeScript client for the Agent Multisig Coordination API.
|
|
5
|
+
* Enables AI agents to participate in multi-signature Bitcoin transactions.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { AgentMultisig } from '@agent-multisig/sdk';
|
|
10
|
+
*
|
|
11
|
+
* const client = new AgentMultisig({
|
|
12
|
+
* apiUrl: 'https://agent-multisig-api-production.up.railway.app',
|
|
13
|
+
* apiKey: 'your-api-key'
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Register an agent
|
|
17
|
+
* const agent = await client.registerAgent({
|
|
18
|
+
* name: 'TreasuryBot',
|
|
19
|
+
* provider: 'aibtc',
|
|
20
|
+
* publicKey: '9350761ae700acd872510de161bca0b90b78ddc007936674b318be8a50c531b5'
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* // Create a 2-of-3 multisig
|
|
24
|
+
* const multisig = await client.createMultisig({
|
|
25
|
+
* name: 'AI Treasury',
|
|
26
|
+
* threshold: 2,
|
|
27
|
+
* agents: [agent1.id, agent2.id, agent3.id],
|
|
28
|
+
* network: 'mainnet'
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* // Create a spend proposal
|
|
32
|
+
* const proposal = await client.createProposal({
|
|
33
|
+
* multisigId: multisig.id,
|
|
34
|
+
* to: 'bc1q...',
|
|
35
|
+
* amount: 10000
|
|
36
|
+
* });
|
|
37
|
+
*
|
|
38
|
+
* // Sign the proposal
|
|
39
|
+
* await client.signProposal(proposal.id, agent.id, signature);
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
interface AgentMultisigConfig {
|
|
43
|
+
apiUrl: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
timeout?: number;
|
|
46
|
+
}
|
|
47
|
+
interface Agent {
|
|
48
|
+
id: string;
|
|
49
|
+
name: string;
|
|
50
|
+
provider: 'aibtc' | 'agentkit' | 'crossmint' | 'clawcash' | 'bankr' | 'custom';
|
|
51
|
+
publicKey: string;
|
|
52
|
+
chain: 'bitcoin' | 'stacks' | 'evm' | 'solana';
|
|
53
|
+
createdAt: string;
|
|
54
|
+
}
|
|
55
|
+
interface RegisterAgentInput {
|
|
56
|
+
name: string;
|
|
57
|
+
provider: Agent['provider'];
|
|
58
|
+
publicKey: string;
|
|
59
|
+
chain?: Agent['chain'];
|
|
60
|
+
webhookUrl?: string;
|
|
61
|
+
metadata?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
interface Multisig {
|
|
64
|
+
id: string;
|
|
65
|
+
name: string;
|
|
66
|
+
address: string;
|
|
67
|
+
threshold: number;
|
|
68
|
+
totalSigners: number;
|
|
69
|
+
agents: string[];
|
|
70
|
+
network: 'mainnet' | 'testnet' | 'signet';
|
|
71
|
+
chain: 'bitcoin' | 'stacks' | 'evm' | 'solana';
|
|
72
|
+
scriptHex?: string;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
}
|
|
75
|
+
interface CreateMultisigInput {
|
|
76
|
+
name: string;
|
|
77
|
+
threshold: number;
|
|
78
|
+
agents: string[];
|
|
79
|
+
network?: 'mainnet' | 'testnet' | 'signet';
|
|
80
|
+
chain?: Multisig['chain'];
|
|
81
|
+
}
|
|
82
|
+
interface Proposal {
|
|
83
|
+
id: string;
|
|
84
|
+
multisigId: string;
|
|
85
|
+
type: 'spend' | 'custom';
|
|
86
|
+
status: 'pending' | 'ready' | 'broadcast' | 'confirmed' | 'failed';
|
|
87
|
+
to?: string;
|
|
88
|
+
amount?: number;
|
|
89
|
+
psbtHex?: string;
|
|
90
|
+
signatures: ProposalSignature[];
|
|
91
|
+
txid?: string;
|
|
92
|
+
createdAt: string;
|
|
93
|
+
expiresAt?: string;
|
|
94
|
+
}
|
|
95
|
+
interface ProposalSignature {
|
|
96
|
+
agentId: string;
|
|
97
|
+
signature: string;
|
|
98
|
+
signedAt: string;
|
|
99
|
+
}
|
|
100
|
+
interface CreateProposalInput {
|
|
101
|
+
multisigId: string;
|
|
102
|
+
to: string;
|
|
103
|
+
amount: number;
|
|
104
|
+
memo?: string;
|
|
105
|
+
}
|
|
106
|
+
interface SignProposalInput {
|
|
107
|
+
proposalId: string;
|
|
108
|
+
agentId: string;
|
|
109
|
+
signature: string;
|
|
110
|
+
}
|
|
111
|
+
declare class AgentMultisigError extends Error {
|
|
112
|
+
statusCode?: number | undefined;
|
|
113
|
+
code?: string | undefined;
|
|
114
|
+
constructor(message: string, statusCode?: number | undefined, code?: string | undefined);
|
|
115
|
+
}
|
|
116
|
+
declare class AgentMultisig {
|
|
117
|
+
private apiUrl;
|
|
118
|
+
private apiKey?;
|
|
119
|
+
private timeout;
|
|
120
|
+
constructor(config: AgentMultisigConfig);
|
|
121
|
+
private request;
|
|
122
|
+
health(): Promise<{
|
|
123
|
+
status: string;
|
|
124
|
+
version: string;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Register a new agent with the coordination API.
|
|
128
|
+
*/
|
|
129
|
+
registerAgent(input: RegisterAgentInput): Promise<Agent>;
|
|
130
|
+
/**
|
|
131
|
+
* Get an agent by ID.
|
|
132
|
+
*/
|
|
133
|
+
getAgent(agentId: string): Promise<Agent>;
|
|
134
|
+
/**
|
|
135
|
+
* List all registered agents.
|
|
136
|
+
*/
|
|
137
|
+
listAgents(): Promise<Agent[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Create a new multisig wallet.
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const multisig = await client.createMultisig({
|
|
144
|
+
* name: 'AI Treasury',
|
|
145
|
+
* threshold: 2,
|
|
146
|
+
* agents: ['agent_abc', 'agent_def', 'agent_ghi'],
|
|
147
|
+
* network: 'mainnet'
|
|
148
|
+
* });
|
|
149
|
+
* console.log('Fund this address:', multisig.address);
|
|
150
|
+
* ```
|
|
151
|
+
*/
|
|
152
|
+
createMultisig(input: CreateMultisigInput): Promise<Multisig>;
|
|
153
|
+
/**
|
|
154
|
+
* Get a multisig by ID.
|
|
155
|
+
*/
|
|
156
|
+
getMultisig(multisigId: string): Promise<Multisig>;
|
|
157
|
+
/**
|
|
158
|
+
* List all multisigs.
|
|
159
|
+
*/
|
|
160
|
+
listMultisigs(): Promise<Multisig[]>;
|
|
161
|
+
/**
|
|
162
|
+
* Get the balance of a multisig wallet.
|
|
163
|
+
*/
|
|
164
|
+
getMultisigBalance(multisigId: string): Promise<{
|
|
165
|
+
confirmed: number;
|
|
166
|
+
unconfirmed: number;
|
|
167
|
+
utxos: Array<{
|
|
168
|
+
txid: string;
|
|
169
|
+
vout: number;
|
|
170
|
+
value: number;
|
|
171
|
+
}>;
|
|
172
|
+
}>;
|
|
173
|
+
/**
|
|
174
|
+
* Create a spend proposal for a multisig.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```typescript
|
|
178
|
+
* const proposal = await client.createProposal({
|
|
179
|
+
* multisigId: 'msig_xyz',
|
|
180
|
+
* to: 'bc1qpzlw29z50cz7ysjpsaqggtscya3p6ggehnsp2g',
|
|
181
|
+
* amount: 10000 // satoshis
|
|
182
|
+
* });
|
|
183
|
+
* console.log('PSBT to sign:', proposal.psbtHex);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
createProposal(input: CreateProposalInput): Promise<Proposal>;
|
|
187
|
+
/**
|
|
188
|
+
* Get a proposal by ID.
|
|
189
|
+
*/
|
|
190
|
+
getProposal(proposalId: string): Promise<Proposal>;
|
|
191
|
+
/**
|
|
192
|
+
* List proposals, optionally filtered by multisig.
|
|
193
|
+
*/
|
|
194
|
+
listProposals(multisigId?: string): Promise<Proposal[]>;
|
|
195
|
+
/**
|
|
196
|
+
* Sign a proposal with an agent's key.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Agent signs the PSBT and submits signature
|
|
201
|
+
* const signature = await myWallet.signPsbt(proposal.psbtHex);
|
|
202
|
+
* await client.signProposal({
|
|
203
|
+
* proposalId: proposal.id,
|
|
204
|
+
* agentId: myAgent.id,
|
|
205
|
+
* signature: signature
|
|
206
|
+
* });
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
signProposal(input: SignProposalInput): Promise<Proposal>;
|
|
210
|
+
/**
|
|
211
|
+
* Broadcast a fully-signed proposal.
|
|
212
|
+
*/
|
|
213
|
+
broadcastProposal(proposalId: string): Promise<{
|
|
214
|
+
txid: string;
|
|
215
|
+
}>;
|
|
216
|
+
/**
|
|
217
|
+
* Create a multisig and register agents in one call.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const { multisig, agents } = await client.quickSetup({
|
|
222
|
+
* name: 'Quick Treasury',
|
|
223
|
+
* threshold: 2,
|
|
224
|
+
* signers: [
|
|
225
|
+
* { name: 'Bot1', provider: 'aibtc', publicKey: '...' },
|
|
226
|
+
* { name: 'Bot2', provider: 'aibtc', publicKey: '...' },
|
|
227
|
+
* { name: 'Bot3', provider: 'aibtc', publicKey: '...' },
|
|
228
|
+
* ]
|
|
229
|
+
* });
|
|
230
|
+
* ```
|
|
231
|
+
*/
|
|
232
|
+
quickSetup(input: {
|
|
233
|
+
name: string;
|
|
234
|
+
threshold: number;
|
|
235
|
+
signers: RegisterAgentInput[];
|
|
236
|
+
network?: 'mainnet' | 'testnet' | 'signet';
|
|
237
|
+
}): Promise<{
|
|
238
|
+
multisig: Multisig;
|
|
239
|
+
agents: Agent[];
|
|
240
|
+
}>;
|
|
241
|
+
/**
|
|
242
|
+
* Wait for a proposal to reach a target status.
|
|
243
|
+
*/
|
|
244
|
+
waitForProposal(proposalId: string, targetStatus: Proposal['status'], options?: {
|
|
245
|
+
timeoutMs?: number;
|
|
246
|
+
pollIntervalMs?: number;
|
|
247
|
+
}): Promise<Proposal>;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export { type Agent, AgentMultisig, type AgentMultisigConfig, AgentMultisigError, type CreateMultisigInput, type CreateProposalInput, type Multisig, type Proposal, type ProposalSignature, type RegisterAgentInput, type SignProposalInput, AgentMultisig as default };
|