@kaleidorg/wallet-engine 1.0.0-beta.12 → 1.0.0-beta.13
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 +13 -5
- package/dist/adapters/RgbAdapter.d.ts.map +1 -1
- package/dist/adapters/RgbAdapter.js +45 -45
- package/dist/adapters/RgbAdapter.js.map +1 -1
- package/dist/adapters/wdk/ArkadeWdkAdapter.d.ts +3 -11
- package/dist/adapters/wdk/ArkadeWdkAdapter.d.ts.map +1 -1
- package/dist/adapters/wdk/ArkadeWdkAdapter.js +22 -36
- package/dist/adapters/wdk/ArkadeWdkAdapter.js.map +1 -1
- package/dist/adapters/wdk/BaseWdkAdapter.d.ts +40 -0
- package/dist/adapters/wdk/BaseWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/BaseWdkAdapter.js +71 -0
- package/dist/adapters/wdk/BaseWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/LiquidWdkAdapter.d.ts +2 -9
- package/dist/adapters/wdk/LiquidWdkAdapter.d.ts.map +1 -1
- package/dist/adapters/wdk/LiquidWdkAdapter.js +5 -27
- package/dist/adapters/wdk/LiquidWdkAdapter.js.map +1 -1
- package/dist/adapters/wdk/RgbCore.d.ts +55 -0
- package/dist/adapters/wdk/RgbCore.d.ts.map +1 -0
- package/dist/adapters/wdk/RgbCore.js +93 -0
- package/dist/adapters/wdk/RgbCore.js.map +1 -0
- package/dist/adapters/wdk/RgbLibWdkAdapter.d.ts +104 -0
- package/dist/adapters/wdk/RgbLibWdkAdapter.d.ts.map +1 -0
- package/dist/adapters/wdk/RgbLibWdkAdapter.js +249 -0
- package/dist/adapters/wdk/RgbLibWdkAdapter.js.map +1 -0
- package/dist/adapters/wdk/RlnWdkAdapter.d.ts +4 -12
- package/dist/adapters/wdk/RlnWdkAdapter.d.ts.map +1 -1
- package/dist/adapters/wdk/RlnWdkAdapter.js +55 -86
- package/dist/adapters/wdk/RlnWdkAdapter.js.map +1 -1
- package/dist/adapters/wdk/SparkWdkAdapter.d.ts +2 -10
- package/dist/adapters/wdk/SparkWdkAdapter.d.ts.map +1 -1
- package/dist/adapters/wdk/SparkWdkAdapter.js +3 -29
- package/dist/adapters/wdk/SparkWdkAdapter.js.map +1 -1
- package/dist/adapters/wdk/index.d.ts +1 -0
- package/dist/adapters/wdk/index.d.ts.map +1 -1
- package/dist/adapters/wdk/index.js +1 -0
- package/dist/adapters/wdk/index.js.map +1 -1
- package/dist/capabilities/index.d.ts.map +1 -1
- package/dist/capabilities/index.js +17 -2
- package/dist/capabilities/index.js.map +1 -1
- package/dist/capabilities/operations.d.ts.map +1 -1
- package/dist/capabilities/operations.js +8 -1
- package/dist/capabilities/operations.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/manager/ProtocolManager.d.ts +1 -1
- package/dist/manager/ProtocolManager.d.ts.map +1 -1
- package/dist/manager/ProtocolManager.js +16 -16
- package/dist/manager/ProtocolManager.js.map +1 -1
- package/dist/receive/unifiedReceive.d.ts +12 -0
- package/dist/receive/unifiedReceive.d.ts.map +1 -1
- package/dist/receive/unifiedReceive.js +35 -4
- package/dist/receive/unifiedReceive.js.map +1 -1
- package/dist/registry/createWdkRegistry.d.ts.map +1 -1
- package/dist/registry/createWdkRegistry.js +7 -2
- package/dist/registry/createWdkRegistry.js.map +1 -1
- package/dist/router/destination.d.ts +1 -1
- package/dist/router/destination.d.ts.map +1 -1
- package/dist/router/destination.js +29 -11
- package/dist/router/destination.js.map +1 -1
- package/dist/router/index.d.ts +36 -0
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +111 -2
- package/dist/router/index.js.map +1 -1
- package/dist/router/preference.d.ts +53 -0
- package/dist/router/preference.d.ts.map +1 -0
- package/dist/router/preference.js +81 -0
- package/dist/router/preference.js.map +1 -0
- package/dist/swap/KaleidoswapSwap.d.ts.map +1 -1
- package/dist/swap/KaleidoswapSwap.js +35 -18
- package/dist/swap/KaleidoswapSwap.js.map +1 -1
- package/dist/types/base.d.ts +1 -1
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/base.js.map +1 -1
- package/dist/types/rgb.d.ts +1 -1
- package/dist/types/rgb.d.ts.map +1 -1
- package/dist/utils.js +2 -2
- package/dist/utils.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RgbLibWdkAdapter
|
|
3
|
+
* ----------------
|
|
4
|
+
* Wraps the local rgb-lib WDK module (@utexo/wdk-wallet-rgb) onto the stable
|
|
5
|
+
* `IProtocolAdapter` contract as the RGB-L1 (on-chain) path: BTC on-chain + RGB
|
|
6
|
+
* assets on-chain, with NO Lightning, channels, or swaps. It is the on-chain
|
|
7
|
+
* subset of the node-backed `RlnWdkAdapter`; the two share their asset/balance/
|
|
8
|
+
* status translation via `RgbCore` so they cannot drift.
|
|
9
|
+
*
|
|
10
|
+
* Unlike the RLN adapter (which talks to a remote rgb-lightning-node over HTTP),
|
|
11
|
+
* this runs rgb-lib locally and holds keys in-process — that's why it lives in
|
|
12
|
+
* the wallet engine rather than in the remote-client kaleido-sdk.
|
|
13
|
+
*
|
|
14
|
+
* Discipline: no WDK/rgb-lib types cross the contract — domain types only; the
|
|
15
|
+
* module account is read as `any` and translated.
|
|
16
|
+
*
|
|
17
|
+
* Wired against @utexo/wdk-wallet-rgb@2.0.3's published types:
|
|
18
|
+
* - WalletManagerRgb(seed, RgbWalletConfig).getAccount() → WalletAccountRgb
|
|
19
|
+
* - account: getAddress / registerWallet()→{address,btcBalance} / listAssets()
|
|
20
|
+
* (sync array) / receiveAsset / transfer(TransferOptions) / createUtxos /
|
|
21
|
+
* signPsbt / refreshWallet / syncWallet / listTransfers / listTransactions.
|
|
22
|
+
* - NO invoice decoder, NO Lightning, NO swaps on the WDK account surface.
|
|
23
|
+
* Per-asset balance rides on listAssets(); BTC balance rides on registerWallet().
|
|
24
|
+
* Response field names (InvoiceReceiveData, BtcBalance, ListAssetsResponse) are
|
|
25
|
+
* read defensively and should still be smoke-tested on-device.
|
|
26
|
+
*/
|
|
27
|
+
import { IProtocolAdapter, BaseProtocolConfig } from '../IProtocolAdapter.js';
|
|
28
|
+
import { ProtocolType, Layer, UnifiedAsset, UnifiedTransaction, InvoiceRequest, Invoice, DecodedInvoice, PaymentRequest, PaymentResult, PaymentStatus, Address, ConnectionInfo, TransactionFilter, NodeInfo } from '../../types/base.js';
|
|
29
|
+
import { BaseWdkAdapter } from './BaseWdkAdapter.js';
|
|
30
|
+
export interface RgbLibAdapterConfig extends BaseProtocolConfig {
|
|
31
|
+
protocol: 'RGB_L1';
|
|
32
|
+
/** BIP-39 mnemonic for this wallet. */
|
|
33
|
+
mnemonic: string;
|
|
34
|
+
/** Persistent directory for the rgb-lib SQLite wallet + data. */
|
|
35
|
+
dataDir: string;
|
|
36
|
+
/** RGB indexer (electrum/esplora) URL. */
|
|
37
|
+
indexerUrl?: string;
|
|
38
|
+
/** RGB proxy / transport endpoint. */
|
|
39
|
+
transportEndpoint?: string;
|
|
40
|
+
}
|
|
41
|
+
export declare class RgbLibWdkAdapter extends BaseWdkAdapter implements IProtocolAdapter {
|
|
42
|
+
readonly protocolName: ProtocolType;
|
|
43
|
+
readonly capabilities: readonly import("../../index.js").ProtocolCapability[];
|
|
44
|
+
readonly supportedLayers: Layer[];
|
|
45
|
+
connect(config: BaseProtocolConfig): Promise<void>;
|
|
46
|
+
getConnectionInfo(): Promise<ConnectionInfo>;
|
|
47
|
+
getReceiveAddress(assetId?: string): Promise<Address>;
|
|
48
|
+
getBtcBalance(): Promise<{
|
|
49
|
+
confirmed: number;
|
|
50
|
+
unconfirmed: number;
|
|
51
|
+
total: number;
|
|
52
|
+
}>;
|
|
53
|
+
refreshBalances(): Promise<void>;
|
|
54
|
+
listAssets(): Promise<UnifiedAsset[]>;
|
|
55
|
+
getAssetBalance(assetId: string): Promise<UnifiedAsset['balance']>;
|
|
56
|
+
getAsset(assetId: string): Promise<UnifiedAsset>;
|
|
57
|
+
createInvoice(request: InvoiceRequest): Promise<Invoice>;
|
|
58
|
+
decodeInvoice(_invoice: string): Promise<DecodedInvoice>;
|
|
59
|
+
sendPayment(_request: PaymentRequest): Promise<PaymentResult>;
|
|
60
|
+
getPaymentStatus(_paymentHash: string): Promise<PaymentStatus>;
|
|
61
|
+
/**
|
|
62
|
+
* BTC-L1 (vanilla) transaction history from rgb-lib. `listTransactions()` is
|
|
63
|
+
* synchronous and returns the wallet's Bitcoin transactions; RGB asset detail
|
|
64
|
+
* is per-asset via `listTransfers({ asset_id })`. Fields are read defensively.
|
|
65
|
+
*/
|
|
66
|
+
listTransactions(_filter?: TransactionFilter): Promise<UnifiedTransaction[]>;
|
|
67
|
+
getTransaction(txId: string): Promise<UnifiedTransaction>;
|
|
68
|
+
getNodeInfo(): Promise<NodeInfo>;
|
|
69
|
+
listChannels(): Promise<unknown[]>;
|
|
70
|
+
listPayments(): Promise<unknown>;
|
|
71
|
+
listTransfers(options?: {
|
|
72
|
+
asset_id?: string;
|
|
73
|
+
}): Promise<unknown>;
|
|
74
|
+
createRgbInvoice(params: any): Promise<any>;
|
|
75
|
+
/**
|
|
76
|
+
* Sign a PSBT with the wallet's keys (rgb-lib signs wallet-owned inputs).
|
|
77
|
+
* Returns the contract's `{ psbt, unchanged }` shape.
|
|
78
|
+
*/
|
|
79
|
+
signPsbt(psbtHex: string): Promise<{
|
|
80
|
+
psbt: string;
|
|
81
|
+
unchanged: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
createRgbUtxos(params: {
|
|
84
|
+
num?: number;
|
|
85
|
+
size?: number;
|
|
86
|
+
feeRate?: number;
|
|
87
|
+
upTo?: boolean;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
success: boolean;
|
|
90
|
+
}>;
|
|
91
|
+
sendAsset(params: {
|
|
92
|
+
token: string;
|
|
93
|
+
recipient: string;
|
|
94
|
+
amount: number;
|
|
95
|
+
feeRate?: number;
|
|
96
|
+
minConfirmations?: number;
|
|
97
|
+
}): Promise<any>;
|
|
98
|
+
sendBtcOnchain(params: {
|
|
99
|
+
address: string;
|
|
100
|
+
amount: number;
|
|
101
|
+
feeRate?: number;
|
|
102
|
+
}): Promise<any>;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=RgbLibWdkAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RgbLibWdkAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/wdk/RgbLibWdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EACL,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,OAAO,EACP,cAAc,EACd,iBAAiB,EAEjB,QAAQ,EAET,MAAM,kBAAkB,CAAA;AAKzB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEjD,MAAM,WAAW,mBAAoB,SAAQ,kBAAkB;IAC7D,QAAQ,EAAE,QAAQ,CAAA;IAClB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAA;IAChB,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAA;IACf,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,sCAAsC;IACtC,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED,qBAAa,gBAAiB,SAAQ,cAAe,YAAW,gBAAgB;IAC9E,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAW;IAC9C,QAAQ,CAAC,YAAY,gDAA6B;IAClD,QAAQ,CAAC,eAAe,EAAE,KAAK,EAAE,CAAmC;IAG9D,OAAO,CAAC,MAAM,EAAE,k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C;IAOhE,gBAAgB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAKjD;;;OAGG;IACG,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC;IAMxE,cAAc,CAAC,MAAM,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAMxH,SAAS,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAKlI,cAAc,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;CAMlG"}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RgbLibWdkAdapter
|
|
3
|
+
* ----------------
|
|
4
|
+
* Wraps the local rgb-lib WDK module (@utexo/wdk-wallet-rgb) onto the stable
|
|
5
|
+
* `IProtocolAdapter` contract as the RGB-L1 (on-chain) path: BTC on-chain + RGB
|
|
6
|
+
* assets on-chain, with NO Lightning, channels, or swaps. It is the on-chain
|
|
7
|
+
* subset of the node-backed `RlnWdkAdapter`; the two share their asset/balance/
|
|
8
|
+
* status translation via `RgbCore` so they cannot drift.
|
|
9
|
+
*
|
|
10
|
+
* Unlike the RLN adapter (which talks to a remote rgb-lightning-node over HTTP),
|
|
11
|
+
* this runs rgb-lib locally and holds keys in-process — that's why it lives in
|
|
12
|
+
* the wallet engine rather than in the remote-client kaleido-sdk.
|
|
13
|
+
*
|
|
14
|
+
* Discipline: no WDK/rgb-lib types cross the contract — domain types only; the
|
|
15
|
+
* module account is read as `any` and translated.
|
|
16
|
+
*
|
|
17
|
+
* Wired against @utexo/wdk-wallet-rgb@2.0.3's published types:
|
|
18
|
+
* - WalletManagerRgb(seed, RgbWalletConfig).getAccount() → WalletAccountRgb
|
|
19
|
+
* - account: getAddress / registerWallet()→{address,btcBalance} / listAssets()
|
|
20
|
+
* (sync array) / receiveAsset / transfer(TransferOptions) / createUtxos /
|
|
21
|
+
* signPsbt / refreshWallet / syncWallet / listTransfers / listTransactions.
|
|
22
|
+
* - NO invoice decoder, NO Lightning, NO swaps on the WDK account surface.
|
|
23
|
+
* Per-asset balance rides on listAssets(); BTC balance rides on registerWallet().
|
|
24
|
+
* Response field names (InvoiceReceiveData, BtcBalance, ListAssetsResponse) are
|
|
25
|
+
* read defensively and should still be smoke-tested on-device.
|
|
26
|
+
*/
|
|
27
|
+
import { ProtocolError, } from '../../types/base.js';
|
|
28
|
+
import { getCapabilities } from '../../capabilities/index.js';
|
|
29
|
+
import { PROTOCOL_OPERATIONS } from '../../capabilities/operations.js';
|
|
30
|
+
import { loadWdkModule } from './moduleLoader.js';
|
|
31
|
+
import { rgbBtcAsset, rgbNiaAsset, rgbAssetBalance, RGB_L1_PROFILE } from './RgbCore.js';
|
|
32
|
+
import { BaseWdkAdapter } from './BaseWdkAdapter.js';
|
|
33
|
+
export class RgbLibWdkAdapter extends BaseWdkAdapter {
|
|
34
|
+
constructor() {
|
|
35
|
+
super(...arguments);
|
|
36
|
+
this.protocolName = 'RGB_L1';
|
|
37
|
+
this.capabilities = PROTOCOL_OPERATIONS.RGB_L1;
|
|
38
|
+
this.supportedLayers = getCapabilities('RGB_L1').layers;
|
|
39
|
+
}
|
|
40
|
+
// --- Connection ---------------------------------------------------------
|
|
41
|
+
async connect(config) {
|
|
42
|
+
const cfg = config;
|
|
43
|
+
if (!cfg.mnemonic)
|
|
44
|
+
throw new ProtocolError('RgbLibWdkAdapter requires a mnemonic', 'RGB_L1', 'CONFIG');
|
|
45
|
+
if (!cfg.dataDir)
|
|
46
|
+
throw new ProtocolError('RgbLibWdkAdapter requires a dataDir', 'RGB_L1', 'CONFIG');
|
|
47
|
+
this.network = cfg.network ?? 'mainnet';
|
|
48
|
+
// @ts-ignore — declared as an optional dep; resolved at runtime.
|
|
49
|
+
const mod = await loadWdkModule('@utexo/wdk-wallet-rgb', () => import('@utexo/wdk-wallet-rgb'));
|
|
50
|
+
const WalletManagerRgb = mod.WalletManagerRgb ?? mod.default ?? mod;
|
|
51
|
+
this.manager = new WalletManagerRgb(cfg.mnemonic, {
|
|
52
|
+
network: this.network,
|
|
53
|
+
dataDir: cfg.dataDir,
|
|
54
|
+
indexerUrl: cfg.indexerUrl,
|
|
55
|
+
transportEndpoint: cfg.transportEndpoint,
|
|
56
|
+
});
|
|
57
|
+
this.account = await this.manager.getAccount();
|
|
58
|
+
// rgb-lib needs the wallet registered with the indexer before first use.
|
|
59
|
+
await this.account.registerWallet?.().catch(() => { });
|
|
60
|
+
this.connected = true;
|
|
61
|
+
}
|
|
62
|
+
async getConnectionInfo() {
|
|
63
|
+
this.assertConnected();
|
|
64
|
+
return { protocol: 'RGB_L1', connected: this.connected, network: this.network };
|
|
65
|
+
}
|
|
66
|
+
// --- Address / receive --------------------------------------------------
|
|
67
|
+
async getReceiveAddress(assetId) {
|
|
68
|
+
this.assertConnected();
|
|
69
|
+
if (assetId) {
|
|
70
|
+
// receiveAsset requires an amount + a witness flag; 0 = "any amount".
|
|
71
|
+
const inv = await this.account.receiveAsset({ assetId, amount: 0, witness: true });
|
|
72
|
+
return { address: inv?.invoice ?? '', format: 'RGB_INVOICE', asset: assetId };
|
|
73
|
+
}
|
|
74
|
+
// The base account exposes getAddress(); registerWallet() also returns it.
|
|
75
|
+
const address = (await this.account.getAddress?.()) ?? (await this.account.registerWallet()).address;
|
|
76
|
+
return { address, format: 'BTC_ADDRESS' };
|
|
77
|
+
}
|
|
78
|
+
// --- Balance ------------------------------------------------------------
|
|
79
|
+
async getBtcBalance() {
|
|
80
|
+
this.assertConnected();
|
|
81
|
+
// The WDK account has no standalone BTC-balance call; registerWallet()
|
|
82
|
+
// returns { address, btcBalance }. btcBalance is the rgb-lib vanilla/colored
|
|
83
|
+
// split; read the vanilla (uncolored) sats.
|
|
84
|
+
const reg = await this.account.registerWallet();
|
|
85
|
+
const v = reg?.btcBalance?.vanilla ?? reg?.btcBalance ?? {};
|
|
86
|
+
const settled = Number(v.settled ?? 0);
|
|
87
|
+
const spendable = Number(v.spendable ?? settled);
|
|
88
|
+
return { confirmed: settled, unconfirmed: Math.max(0, Number(v.future ?? spendable) - settled), total: spendable };
|
|
89
|
+
}
|
|
90
|
+
async refreshBalances() {
|
|
91
|
+
this.assertConnected();
|
|
92
|
+
// refreshWallet()/syncWallet() are synchronous void on the WDK account.
|
|
93
|
+
try {
|
|
94
|
+
this.account.refreshWallet?.();
|
|
95
|
+
this.account.syncWallet?.();
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* best-effort */
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async listAssets() {
|
|
102
|
+
this.assertConnected();
|
|
103
|
+
const { total } = await this.getBtcBalance();
|
|
104
|
+
const out = [rgbBtcAsset(total, RGB_L1_PROFILE)];
|
|
105
|
+
// listAssets() is synchronous and returns the asset array directly (it may
|
|
106
|
+
// also come wrapped as { nia, cfa, uda } depending on rgb-sdk version).
|
|
107
|
+
const res = await this.account.listAssets();
|
|
108
|
+
const assets = Array.isArray(res) ? res : res?.nia ?? res?.assets?.nia ?? [];
|
|
109
|
+
for (const a of assets)
|
|
110
|
+
out.push(rgbNiaAsset(normalizeAsset(a), RGB_L1_PROFILE));
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
async getAssetBalance(assetId) {
|
|
114
|
+
this.assertConnected();
|
|
115
|
+
// No standalone balance call; the per-asset balance rides on listAssets().
|
|
116
|
+
const a = (await this.listAssets()).find((x) => x.id === assetId);
|
|
117
|
+
return a?.balance ?? rgbAssetBalance({});
|
|
118
|
+
}
|
|
119
|
+
async getAsset(assetId) {
|
|
120
|
+
const assets = await this.listAssets();
|
|
121
|
+
const found = assets.find((a) => a.id === assetId);
|
|
122
|
+
if (!found)
|
|
123
|
+
throw new ProtocolError(`Unknown asset ${assetId}`, 'RGB_L1', 'NO_ASSET');
|
|
124
|
+
return found;
|
|
125
|
+
}
|
|
126
|
+
// --- Invoices -----------------------------------------------------------
|
|
127
|
+
async createInvoice(request) {
|
|
128
|
+
this.assertConnected();
|
|
129
|
+
// RGB-L1 has no Lightning: only RGB asset invoices are supported.
|
|
130
|
+
if (!request.asset || request.asset === 'BTC') {
|
|
131
|
+
throw new ProtocolError('RGB-L1 has no Lightning invoices; use getReceiveAddress for BTC', 'RGB_L1', 'NOT_SUPPORTED');
|
|
132
|
+
}
|
|
133
|
+
const inv = await this.account.receiveAsset({
|
|
134
|
+
assetId: request.asset,
|
|
135
|
+
amount: request.assetAmount ?? 0, // amount is required; 0 = any amount
|
|
136
|
+
witness: true,
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
invoice: inv?.invoice ?? '',
|
|
140
|
+
paymentHash: inv?.recipientId ?? inv?.recipient_id ?? '',
|
|
141
|
+
amount: request.assetAmount,
|
|
142
|
+
expiresAt: inv?.expirationTimestamp ? inv.expirationTimestamp * 1000 : Date.now() + (request.expirySeconds ?? 3600) * 1000,
|
|
143
|
+
description: request.description,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async decodeInvoice(_invoice) {
|
|
147
|
+
// The WDK account does not expose an invoice decoder; decoding would require
|
|
148
|
+
// dropping to getRgbWallet() (the underlying rgb-sdk). Not supported here.
|
|
149
|
+
throw new ProtocolError('RGB-L1 adapter does not decode invoices', 'RGB_L1', 'NOT_SUPPORTED');
|
|
150
|
+
}
|
|
151
|
+
// --- Send ---------------------------------------------------------------
|
|
152
|
+
async sendPayment(_request) {
|
|
153
|
+
// No Lightning on RGB-L1; on-chain sends go through sendAsset / sendBtcOnchain.
|
|
154
|
+
throw new ProtocolError('RGB-L1 has no Lightning send; use sendAsset or sendBtcOnchain', 'RGB_L1', 'NOT_SUPPORTED');
|
|
155
|
+
}
|
|
156
|
+
async getPaymentStatus(_paymentHash) {
|
|
157
|
+
throw new ProtocolError('RGB-L1 has no Lightning payment status', 'RGB_L1', 'NOT_SUPPORTED');
|
|
158
|
+
}
|
|
159
|
+
// --- Transactions -------------------------------------------------------
|
|
160
|
+
/**
|
|
161
|
+
* BTC-L1 (vanilla) transaction history from rgb-lib. `listTransactions()` is
|
|
162
|
+
* synchronous and returns the wallet's Bitcoin transactions; RGB asset detail
|
|
163
|
+
* is per-asset via `listTransfers({ asset_id })`. Fields are read defensively.
|
|
164
|
+
*/
|
|
165
|
+
async listTransactions(_filter) {
|
|
166
|
+
this.assertConnected();
|
|
167
|
+
const raw = await this.account.listTransactions();
|
|
168
|
+
const txs = Array.isArray(raw) ? raw : raw?.transactions ?? [];
|
|
169
|
+
return txs.map((t) => {
|
|
170
|
+
const received = Number(t.received ?? 0);
|
|
171
|
+
const sent = Number(t.sent ?? 0);
|
|
172
|
+
const confTime = t.confirmation_time ?? t.confirmationTime;
|
|
173
|
+
return {
|
|
174
|
+
id: t.txid ?? t.transaction_id ?? '',
|
|
175
|
+
type: (received >= sent ? 'receive' : 'send'),
|
|
176
|
+
status: (confTime ? 'confirmed' : 'pending'),
|
|
177
|
+
timestamp: Number(confTime?.timestamp ?? 0) * 1000,
|
|
178
|
+
amount: Math.abs(received - sent) || received || sent,
|
|
179
|
+
amountDisplay: '',
|
|
180
|
+
asset: undefined,
|
|
181
|
+
protocolData: t,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
async getTransaction(txId) {
|
|
186
|
+
const found = (await this.listTransactions()).find((t) => t.id === txId);
|
|
187
|
+
if (!found)
|
|
188
|
+
throw new ProtocolError(`Unknown tx ${txId}`, 'RGB_L1', 'NO_TX');
|
|
189
|
+
return found;
|
|
190
|
+
}
|
|
191
|
+
async getNodeInfo() {
|
|
192
|
+
// No node: RGB-L1 is a local rgb-lib wallet.
|
|
193
|
+
return {};
|
|
194
|
+
}
|
|
195
|
+
async listChannels() {
|
|
196
|
+
return [];
|
|
197
|
+
}
|
|
198
|
+
async listPayments() {
|
|
199
|
+
return [];
|
|
200
|
+
}
|
|
201
|
+
async listTransfers(options) {
|
|
202
|
+
this.assertConnected();
|
|
203
|
+
if (!options?.asset_id)
|
|
204
|
+
return { transfers: [] };
|
|
205
|
+
return this.account.listTransfers(options.asset_id);
|
|
206
|
+
}
|
|
207
|
+
// --- Optional RGB-specific hooks ----------------------------------------
|
|
208
|
+
async createRgbInvoice(params) {
|
|
209
|
+
this.assertConnected();
|
|
210
|
+
return this.account.receiveAsset(params);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Sign a PSBT with the wallet's keys (rgb-lib signs wallet-owned inputs).
|
|
214
|
+
* Returns the contract's `{ psbt, unchanged }` shape.
|
|
215
|
+
*/
|
|
216
|
+
async signPsbt(psbtHex) {
|
|
217
|
+
this.assertConnected();
|
|
218
|
+
const signed = await this.account.signPsbt(psbtHex);
|
|
219
|
+
return { psbt: signed ?? psbtHex, unchanged: !signed || signed === psbtHex };
|
|
220
|
+
}
|
|
221
|
+
async createRgbUtxos(params) {
|
|
222
|
+
this.assertConnected();
|
|
223
|
+
await this.account.createUtxos(params);
|
|
224
|
+
return { success: true };
|
|
225
|
+
}
|
|
226
|
+
async sendAsset(params) {
|
|
227
|
+
this.assertConnected();
|
|
228
|
+
return this.account.transfer(params);
|
|
229
|
+
}
|
|
230
|
+
async sendBtcOnchain(params) {
|
|
231
|
+
this.assertConnected();
|
|
232
|
+
await this.account.sendTransaction({ to: params.address, value: params.amount, feeRate: params.feeRate });
|
|
233
|
+
return { ok: true };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Normalize an rgb-sdk asset record (which may use camelCase `assetId` or
|
|
238
|
+
* snake_case `asset_id`) into the shape `RgbCore.rgbNiaAsset` expects.
|
|
239
|
+
*/
|
|
240
|
+
function normalizeAsset(a) {
|
|
241
|
+
return {
|
|
242
|
+
asset_id: a?.assetId ?? a?.asset_id ?? a?.id ?? '',
|
|
243
|
+
name: a?.name,
|
|
244
|
+
ticker: a?.ticker,
|
|
245
|
+
precision: a?.precision,
|
|
246
|
+
balance: a?.balance,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=RgbLibWdkAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RgbLibWdkAdapter.js","sourceRoot":"","sources":["../../../src/adapters/wdk/RgbLibWdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,EAgBL,aAAa,GACd,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AACrF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAcjD,MAAM,OAAO,gBAAiB,SAAQ,cAAc;IAApD;;QACW,iBAAY,GAAiB,QAAQ,CAAA;QACrC,iBAAY,GAAG,mBAAmB,CAAC,MAAM,CAAA;QACzC,oBAAe,GAAY,eAAe,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;IAuNtE,CAA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E,EAAE,IAAI,EAAE,CAAA;IACrB,CAAC;CAEF;AAED;;;GAGG;AACH,SAAS,cAAc,CAAC,CAAM;IAO5B,OAAO;QACL,QAAQ,EAAE,CAAC,EAAE,OAAO,IAAI,CAAC,EAAE,QAAQ,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE;QAClD,IAAI,EAAE,CAAC,EAAE,IAAI;QACb,MAAM,EAAE,CAAC,EAAE,MAAM;QACjB,SAAS,EAAE,CAAC,EAAE,SAAS;QACvB,OAAO,EAAE,CAAC,EAAE,OAAO;KACpB,CAAA;AACH,CAAC"}
|
|
@@ -18,8 +18,9 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { IProtocolAdapter, BaseProtocolConfig } from '../IProtocolAdapter.js';
|
|
20
20
|
import { ProtocolType, Layer, UnifiedAsset, UnifiedTransaction, InvoiceRequest, Invoice, DecodedInvoice, PaymentRequest, PaymentResult, PaymentStatus, Address, ConnectionInfo, TransactionFilter } from '../../types/base.js';
|
|
21
|
+
import { BaseWdkAdapter } from './BaseWdkAdapter.js';
|
|
21
22
|
export interface RlnAdapterConfig extends BaseProtocolConfig {
|
|
22
|
-
protocol: '
|
|
23
|
+
protocol: 'RGB_LN';
|
|
23
24
|
/** BIP-39 mnemonic for this wallet. */
|
|
24
25
|
mnemonic: string;
|
|
25
26
|
/** Base URL of the RLN HTTP API (e.g. http://localhost:3001). */
|
|
@@ -27,18 +28,11 @@ export interface RlnAdapterConfig extends BaseProtocolConfig {
|
|
|
27
28
|
/** BIP-44 account index (default 0). */
|
|
28
29
|
accountIndex?: number;
|
|
29
30
|
}
|
|
30
|
-
export declare class RlnWdkAdapter implements IProtocolAdapter {
|
|
31
|
+
export declare class RlnWdkAdapter extends BaseWdkAdapter implements IProtocolAdapter {
|
|
31
32
|
readonly protocolName: ProtocolType;
|
|
32
33
|
readonly capabilities: readonly import("../../index.js").ProtocolCapability[];
|
|
33
34
|
readonly supportedLayers: Layer[];
|
|
34
|
-
readonly version = "0.1.0-wdk";
|
|
35
|
-
private manager;
|
|
36
|
-
private account;
|
|
37
|
-
private connected;
|
|
38
|
-
private network;
|
|
39
35
|
connect(config: BaseProtocolConfig): Promise<void>;
|
|
40
|
-
disconnect(): Promise<void>;
|
|
41
|
-
isConnected(): boolean;
|
|
42
36
|
getConnectionInfo(): Promise<ConnectionInfo>;
|
|
43
37
|
getReceiveAddress(assetId?: string): Promise<Address>;
|
|
44
38
|
getBtcBalance(): Promise<{
|
|
@@ -78,9 +72,7 @@ export declare class RlnWdkAdapter implements IProtocolAdapter {
|
|
|
78
72
|
amount: number;
|
|
79
73
|
feeRate?: number;
|
|
80
74
|
}): Promise<any>;
|
|
81
|
-
|
|
82
|
-
/** Generic escape hatch for RLN-specific ops not on the core contract. */
|
|
75
|
+
/** Generic escape hatch for RLN-specific ops not on the core contract (allowlisted). */
|
|
83
76
|
executeProtocolOperation(operation: string, params: any): Promise<any>;
|
|
84
|
-
private assertConnected;
|
|
85
77
|
}
|
|
86
78
|
//# sourceMappingURL=RlnWdkAdapter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RlnWdkAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/wdk/RlnWdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EACL,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,EACb,OAAO,EACP,cAAc,EACd,iBAAiB,EAGlB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"RlnWdkAdapter.d.ts","sourceRoot":"","sources":["../../../src/adapters/wdk/RlnWdkAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,gBAAgB,E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MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAOjG,wFAAwF;IAClF,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;CAG7E"}
|
|
@@ -20,33 +20,55 @@ import { ProtocolError, } from '../../types/base.js';
|
|
|
20
20
|
import { getCapabilities } from '../../capabilities/index.js';
|
|
21
21
|
import { PROTOCOL_OPERATIONS } from '../../capabilities/operations.js';
|
|
22
22
|
import { loadWdkModule } from './moduleLoader.js';
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
import { isBolt11 } from '../../lib/bolt11.js';
|
|
24
|
+
import { mapRgbStatus, rgbBtcAsset, rgbNiaAsset, rgbAssetBalance, RLN_PROFILE } from './RgbCore.js';
|
|
25
|
+
import { BaseWdkAdapter } from './BaseWdkAdapter.js';
|
|
26
|
+
/**
|
|
27
|
+
* Allowlist of RLN account methods reachable via `executeProtocolOperation`.
|
|
28
|
+
* Only RLN-specific operations not already exposed as typed adapter methods.
|
|
29
|
+
* Anything not listed here is rejected — see the method's SECURITY note.
|
|
30
|
+
*/
|
|
31
|
+
const RLN_ALLOWED_OPS = new Set([
|
|
32
|
+
'openChannel',
|
|
33
|
+
'closeChannel',
|
|
34
|
+
'getChannelId',
|
|
35
|
+
'connectPeer',
|
|
36
|
+
'disconnectPeer',
|
|
37
|
+
'listPeers',
|
|
38
|
+
'keysend',
|
|
39
|
+
'createUtxos',
|
|
40
|
+
'listUnspents',
|
|
41
|
+
'estimateFee',
|
|
42
|
+
'failTransfers',
|
|
43
|
+
'syncRgbWallet',
|
|
44
|
+
'getAssetMetadata',
|
|
45
|
+
'getAssetMedia',
|
|
46
|
+
'whitelistSwap',
|
|
47
|
+
'getTakerPubkey',
|
|
48
|
+
'atomicTaker',
|
|
49
|
+
'listSwaps',
|
|
50
|
+
'getSwap',
|
|
51
|
+
'makerInit',
|
|
52
|
+
'makerExecute',
|
|
53
|
+
'backup',
|
|
54
|
+
'restore',
|
|
55
|
+
'changePassword',
|
|
56
|
+
'signMessage',
|
|
57
|
+
]);
|
|
58
|
+
export class RlnWdkAdapter extends BaseWdkAdapter {
|
|
33
59
|
constructor() {
|
|
34
|
-
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.manager = null;
|
|
39
|
-
this.account = null;
|
|
40
|
-
this.connected = false;
|
|
41
|
-
this.network = 'mainnet';
|
|
60
|
+
super(...arguments);
|
|
61
|
+
this.protocolName = 'RGB_LN';
|
|
62
|
+
this.capabilities = PROTOCOL_OPERATIONS.RGB_LN;
|
|
63
|
+
this.supportedLayers = getCapabilities('RGB_LN').layers;
|
|
42
64
|
}
|
|
43
65
|
// --- Connection ---------------------------------------------------------
|
|
44
66
|
async connect(config) {
|
|
45
67
|
const cfg = config;
|
|
46
68
|
if (!cfg.mnemonic)
|
|
47
|
-
throw new ProtocolError('RlnWdkAdapter requires a mnemonic', '
|
|
69
|
+
throw new ProtocolError('RlnWdkAdapter requires a mnemonic', 'RGB_LN', 'CONFIG');
|
|
48
70
|
if (!cfg.nodeUrl)
|
|
49
|
-
throw new ProtocolError('RlnWdkAdapter requires a nodeUrl', '
|
|
71
|
+
throw new ProtocolError('RlnWdkAdapter requires a nodeUrl', 'RGB_LN', 'CONFIG');
|
|
50
72
|
this.network = cfg.network ?? 'mainnet';
|
|
51
73
|
// @ts-ignore — declared as a workspace/optional dep; resolved at runtime.
|
|
52
74
|
const mod = await loadWdkModule('@kaleidorg/wdk-wallet-rln', () => import('@kaleidorg/wdk-wallet-rln'));
|
|
@@ -55,25 +77,11 @@ export class RlnWdkAdapter {
|
|
|
55
77
|
this.account = await this.manager.getAccount(cfg.accountIndex ?? 0);
|
|
56
78
|
this.connected = true;
|
|
57
79
|
}
|
|
58
|
-
async disconnect() {
|
|
59
|
-
try {
|
|
60
|
-
this.account?.dispose?.();
|
|
61
|
-
this.manager?.dispose?.();
|
|
62
|
-
}
|
|
63
|
-
finally {
|
|
64
|
-
this.account = null;
|
|
65
|
-
this.manager = null;
|
|
66
|
-
this.connected = false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
isConnected() {
|
|
70
|
-
return this.connected;
|
|
71
|
-
}
|
|
72
80
|
async getConnectionInfo() {
|
|
73
81
|
this.assertConnected();
|
|
74
82
|
const info = await this.account.getNodeInfo();
|
|
75
83
|
return {
|
|
76
|
-
protocol: '
|
|
84
|
+
protocol: 'RGB_LN',
|
|
77
85
|
connected: this.connected,
|
|
78
86
|
nodeId: info?.pubkey,
|
|
79
87
|
network: this.network,
|
|
@@ -105,49 +113,25 @@ export class RlnWdkAdapter {
|
|
|
105
113
|
}
|
|
106
114
|
async listAssets() {
|
|
107
115
|
this.assertConnected();
|
|
108
|
-
const out = [];
|
|
109
|
-
// BTC
|
|
110
116
|
const { total } = await this.getBtcBalance();
|
|
111
|
-
out
|
|
112
|
-
id: 'BTC',
|
|
113
|
-
name: 'Bitcoin',
|
|
114
|
-
ticker: 'BTC',
|
|
115
|
-
precision: 8,
|
|
116
|
-
protocol: 'RGB',
|
|
117
|
-
layer: 'BTC_L1',
|
|
118
|
-
balance: { total, available: total, pending: 0, totalDisplay: String(total), availableDisplay: String(total) },
|
|
119
|
-
capabilities: { canSend: true, canReceive: true, canSwap: true, supportsLightning: true, supportsOnchain: true },
|
|
120
|
-
});
|
|
117
|
+
const out = [rgbBtcAsset(total, RLN_PROFILE)];
|
|
121
118
|
// RGB assets (NIA — fungible: USDT/XAUT)
|
|
122
119
|
const res = await this.account.listAssets(['Nia']);
|
|
123
120
|
const nia = res?.nia ?? [];
|
|
124
|
-
for (const a of nia)
|
|
125
|
-
|
|
126
|
-
const total = Number(bal.spendable ?? bal.settled ?? 0);
|
|
127
|
-
out.push({
|
|
128
|
-
id: a.asset_id,
|
|
129
|
-
name: a.name ?? a.ticker ?? a.asset_id,
|
|
130
|
-
ticker: a.ticker ?? a.asset_id?.slice(0, 6),
|
|
131
|
-
precision: Number(a.precision ?? 0),
|
|
132
|
-
protocol: 'RGB',
|
|
133
|
-
layer: 'RGB_LN',
|
|
134
|
-
balance: { total, available: total, pending: 0, totalDisplay: String(total), availableDisplay: String(total) },
|
|
135
|
-
capabilities: { canSend: true, canReceive: true, canSwap: true, supportsLightning: true, supportsOnchain: true },
|
|
136
|
-
});
|
|
137
|
-
}
|
|
121
|
+
for (const a of nia)
|
|
122
|
+
out.push(rgbNiaAsset(a, RLN_PROFILE));
|
|
138
123
|
return out;
|
|
139
124
|
}
|
|
140
125
|
async getAssetBalance(assetId) {
|
|
141
126
|
this.assertConnected();
|
|
142
127
|
const b = await this.account.getAssetBalance(assetId);
|
|
143
|
-
|
|
144
|
-
return { total, available: total, pending: Number(b?.future ?? 0), totalDisplay: String(total), availableDisplay: String(total) };
|
|
128
|
+
return rgbAssetBalance(b);
|
|
145
129
|
}
|
|
146
130
|
async getAsset(assetId) {
|
|
147
131
|
const assets = await this.listAssets();
|
|
148
132
|
const found = assets.find((a) => a.id === assetId);
|
|
149
133
|
if (!found)
|
|
150
|
-
throw new ProtocolError(`Unknown asset ${assetId}`, '
|
|
134
|
+
throw new ProtocolError(`Unknown asset ${assetId}`, 'RGB_LN', 'NO_ASSET');
|
|
151
135
|
return found;
|
|
152
136
|
}
|
|
153
137
|
// --- Invoices -----------------------------------------------------------
|
|
@@ -184,8 +168,7 @@ export class RlnWdkAdapter {
|
|
|
184
168
|
}
|
|
185
169
|
async decodeInvoice(invoice) {
|
|
186
170
|
this.assertConnected();
|
|
187
|
-
const
|
|
188
|
-
const d = isBolt11
|
|
171
|
+
const d = isBolt11(invoice)
|
|
189
172
|
? await this.account.decodeLNInvoice(invoice)
|
|
190
173
|
: await this.account.decodeRgbInvoice(invoice);
|
|
191
174
|
return {
|
|
@@ -209,14 +192,14 @@ export class RlnWdkAdapter {
|
|
|
209
192
|
preimage: r?.payment_secret,
|
|
210
193
|
amount: Number(request.amount ?? 0),
|
|
211
194
|
fee: 0,
|
|
212
|
-
status:
|
|
195
|
+
status: mapRgbStatus(r?.status),
|
|
213
196
|
timestamp: Date.now(),
|
|
214
197
|
};
|
|
215
198
|
}
|
|
216
199
|
async getPaymentStatus(paymentHash) {
|
|
217
200
|
this.assertConnected();
|
|
218
201
|
const s = await this.account.getInvoiceStatus({ paymentHash });
|
|
219
|
-
return { paymentHash, status:
|
|
202
|
+
return { paymentHash, status: mapRgbStatus(s?.status), error: s?.error };
|
|
220
203
|
}
|
|
221
204
|
// --- Transactions / payments -------------------------------------------
|
|
222
205
|
async listTransactions(_filter) {
|
|
@@ -238,7 +221,7 @@ export class RlnWdkAdapter {
|
|
|
238
221
|
const all = await this.listTransactions();
|
|
239
222
|
const found = all.find((t) => t.id === txId);
|
|
240
223
|
if (!found)
|
|
241
|
-
throw new ProtocolError(`Unknown tx ${txId}`, '
|
|
224
|
+
throw new ProtocolError(`Unknown tx ${txId}`, 'RGB_LN', 'NO_TX');
|
|
242
225
|
return found;
|
|
243
226
|
}
|
|
244
227
|
async getNodeInfo() {
|
|
@@ -287,24 +270,10 @@ export class RlnWdkAdapter {
|
|
|
287
270
|
await this.account.sendBtc(params);
|
|
288
271
|
return { ok: true };
|
|
289
272
|
}
|
|
290
|
-
// ---
|
|
291
|
-
|
|
292
|
-
return getCapabilities('RGB').supportsSwaps;
|
|
293
|
-
}
|
|
294
|
-
/** Generic escape hatch for RLN-specific ops not on the core contract. */
|
|
273
|
+
// --- Escape hatch -------------------------------------------------------
|
|
274
|
+
/** Generic escape hatch for RLN-specific ops not on the core contract (allowlisted). */
|
|
295
275
|
async executeProtocolOperation(operation, params) {
|
|
296
|
-
this.
|
|
297
|
-
const fn = this.account[operation];
|
|
298
|
-
if (typeof fn !== 'function') {
|
|
299
|
-
throw new ProtocolError(`Unknown RLN operation '${operation}'`, 'RGB', 'NO_OP');
|
|
300
|
-
}
|
|
301
|
-
return fn.call(this.account, params);
|
|
302
|
-
}
|
|
303
|
-
// --- helpers ------------------------------------------------------------
|
|
304
|
-
assertConnected() {
|
|
305
|
-
if (!this.connected || !this.account) {
|
|
306
|
-
throw new ProtocolError('RlnWdkAdapter not connected', 'RGB', 'NOT_CONNECTED');
|
|
307
|
-
}
|
|
276
|
+
return this.runAllowlistedOp(RLN_ALLOWED_OPS, operation, params);
|
|
308
277
|
}
|
|
309
278
|
}
|
|
310
279
|
//# sourceMappingURL=RlnWdkAdapter.js.map
|