Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add support for new TAP channel RPCs #38

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion lib/api/tapd.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { serviceNames as sn } from '../types/proto/schema';
import { AssetWallet } from '../types/proto/tapd/assetwalletrpc/assetwallet';
import { Mint } from '../types/proto/tapd/mintrpc/mint';
import { PriceOracle } from '../types/proto/tapd/priceoraclerpc/price_oracle';
import { Rfq } from '../types/proto/tapd/rfqrpc/rfq';
import { TaprootAssetChannels } from '../types/proto/tapd/tapchannelrpc/tapchannel';
import { TapDev } from '../types/proto/tapd/tapdevrpc/tapdev';
import { TaprootAssets } from '../types/proto/tapd/taprootassets';
import { Universe } from '../types/proto/tapd/universerpc/universe';

Expand All @@ -11,12 +15,23 @@ class TaprootAssetsApi {
taprootAssets: TaprootAssets;
assetWallet: AssetWallet;
mint: Mint;
priceOracle: PriceOracle;
rfq: Rfq;
tapChannels: TaprootAssetChannels;
tapDev: TapDev;
universe: Universe;

constructor(createRpc: Function, lnc: any) {
this.taprootAssets = createRpc(sn.taprpc.TaprootAssets, lnc);
this.mint = createRpc(sn.mintrpc.Mint, lnc);
this.assetWallet = createRpc(sn.assetwalletrpc.AssetWallet, lnc);
this.mint = createRpc(sn.mintrpc.Mint, lnc);
this.priceOracle = createRpc(sn.priceoraclerpc.PriceOracle, lnc);
this.rfq = createRpc(sn.rfqrpc.Rfq, lnc);
this.tapChannels = createRpc(
sn.tapchannelrpc.TaprootAssetChannels,
lnc
);
this.tapDev = createRpc(sn.tapdevrpc.TapDev, lnc);
this.universe = createRpc(sn.universerpc.Universe, lnc);
}
}
Expand Down
8 changes: 8 additions & 0 deletions lib/types/proto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import * as looprpc from './looprpc';
import * as poolrpc from './poolrpc';
import * as assetwalletrpc from './assetwalletrpc';
import * as mintrpc from './mintrpc';
import * as priceoraclerpc from './priceoraclerpc';
import * as rfqrpc from './rfqrpc';
import * as tapchannelrpc from './tapchannelrpc';
import * as tapdevrpc from './tapdevrpc';
import * as taprpc from './taprpc';
import * as universerpc from './universerpc';
export {
Expand All @@ -31,6 +35,10 @@ export {
poolrpc,
assetwalletrpc,
mintrpc,
priceoraclerpc,
rfqrpc,
tapchannelrpc,
tapdevrpc,
taprpc,
universerpc
};
64 changes: 63 additions & 1 deletion lib/types/proto/lnd/invoicesrpc/invoices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,57 @@ export interface LookupInvoiceMsg {
lookupModifier: LookupModifier;
}

/** CircuitKey is a unique identifier for an HTLC. */
export interface CircuitKey {
/** The id of the channel that the is part of this circuit. */
chanId: string;
/** The index of the incoming htlc in the incoming channel. */
htlcId: string;
}

export interface HtlcModifyRequest {
/**
* The invoice the intercepted HTLC is attempting to settle. The HTLCs in
* the invoice are only HTLCs that have already been accepted or settled,
* not including the current intercepted HTLC.
*/
invoice: Invoice | undefined;
/** The unique identifier of the HTLC of this intercepted HTLC. */
exitHtlcCircuitKey: CircuitKey | undefined;
/** The amount in milli-satoshi that the exit HTLC is attempting to pay. */
exitHtlcAmt: string;
/** The absolute expiry height of the exit HTLC. */
exitHtlcExpiry: number;
/** The current block height. */
currentHeight: number;
/** The wire message custom records of the exit HTLC. */
exitHtlcWireCustomRecords: { [key: string]: Uint8Array | string };
}

export interface HtlcModifyRequest_ExitHtlcWireCustomRecordsEntry {
key: string;
value: Uint8Array | string;
}

export interface HtlcModifyResponse {
/** The circuit key of the HTLC that the client wants to modify. */
circuitKey: CircuitKey | undefined;
/**
* The modified amount in milli-satoshi that the exit HTLC is paying. This
* value can be different from the actual on-chain HTLC amount, in case the
* HTLC carries other valuable items, as can be the case with custom channel
* types.
*/
amtPaid?: string | undefined;
/**
* This flag indicates whether the HTLCs associated with the invoices should
* be cancelled. The interceptor client may set this field if some
* unexpected behavior is encountered. Setting this will ignore the amt_paid
* field.
*/
cancelSet: boolean;
}

/**
* Invoices is a service that can be used to create, accept, settle and cancel
* invoices.
Expand Down Expand Up @@ -162,10 +213,21 @@ export interface Invoices {
request?: DeepPartial<SettleInvoiceMsg>
): Promise<SettleInvoiceResp>;
/**
* LookupInvoiceV2 attempts to look up at invoice. An invoice can be refrenced
* LookupInvoiceV2 attempts to look up at invoice. An invoice can be referenced
* using either its payment hash, payment address, or set ID.
*/
lookupInvoiceV2(request?: DeepPartial<LookupInvoiceMsg>): Promise<Invoice>;
/**
* HtlcModifier is a bidirectional streaming RPC that allows a client to
* intercept and modify the HTLCs that attempt to settle the given invoice. The
* server will send HTLCs of invoices to the client and the client can modify
* some aspects of the HTLC in order to pass the invoice acceptance tests.
*/
htlcModifier(
request?: DeepPartial<HtlcModifyResponse>,
onMessage?: (msg: HtlcModifyRequest) => void,
onError?: (err: Error) => void
): void;
}

type Builtin =
Expand Down
122 changes: 118 additions & 4 deletions lib/types/proto/lnd/lightning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,17 @@ export enum CommitmentType {
* channel before its maturity date.
*/
SCRIPT_ENFORCED_LEASE = 'SCRIPT_ENFORCED_LEASE',
/** SIMPLE_TAPROOT - TODO(roasbeef): need script enforce mirror type for the above as well? */
/**
* SIMPLE_TAPROOT - A channel that uses musig2 for the funding output, and the new tapscript
* features where relevant.
*/
SIMPLE_TAPROOT = 'SIMPLE_TAPROOT',
/**
* SIMPLE_TAPROOT_OVERLAY - Identical to the SIMPLE_TAPROOT channel type, but with extra functionality.
* This channel type also commits to additional meta data in the tapscript
* leaves for the scripts in a channel.
*/
SIMPLE_TAPROOT_OVERLAY = 'SIMPLE_TAPROOT_OVERLAY',
UNRECOGNIZED = 'UNRECOGNIZED'
}

Expand Down Expand Up @@ -164,6 +173,8 @@ export enum PaymentFailureReason {
FAILURE_REASON_INCORRECT_PAYMENT_DETAILS = 'FAILURE_REASON_INCORRECT_PAYMENT_DETAILS',
/** FAILURE_REASON_INSUFFICIENT_BALANCE - Insufficient local balance. */
FAILURE_REASON_INSUFFICIENT_BALANCE = 'FAILURE_REASON_INSUFFICIENT_BALANCE',
/** FAILURE_REASON_CANCELED - The payment was canceled. */
FAILURE_REASON_CANCELED = 'FAILURE_REASON_CANCELED',
UNRECOGNIZED = 'UNRECOGNIZED'
}

Expand Down Expand Up @@ -729,9 +740,8 @@ export interface SendCoinsRequest {
*/
satPerByte: string;
/**
* If set, then the amount field will be ignored, and lnd will attempt to
* send all the coins under control of the internal wallet to the specified
* address.
* If set, the amount field should be unset. It indicates lnd will send all
* wallet coins or all selected coins to the specified address.
*/
sendAll: boolean;
/** An optional label for the transaction, limited to 500 characters. */
Expand All @@ -745,6 +755,8 @@ export interface SendCoinsRequest {
spendUnconfirmed: boolean;
/** The strategy to use for selecting coins. */
coinSelectionStrategy: CoinSelectionStrategy;
/** A list of selected outpoints as inputs for the transaction. */
outpoints: OutPoint[];
}

export interface SendCoinsResponse {
Expand Down Expand Up @@ -1027,6 +1039,8 @@ export interface Channel {
* the channel's operation.
*/
memo: string;
/** Custom channel data that might be populated in custom channels. */
customChannelData: Uint8Array | string;
}

export interface ListChannelsRequest {
Expand Down Expand Up @@ -1356,9 +1370,39 @@ export interface ChannelOpenUpdate {
channelPoint: ChannelPoint | undefined;
}

export interface CloseOutput {
/**
* The amount in satoshi of this close output. This amount is the final
* commitment balance of the channel and the actual amount paid out on chain
* might be smaller due to subtracted fees.
*/
amountSat: string;
/** The pkScript of the close output. */
pkScript: Uint8Array | string;
/** Whether this output is for the local or remote node. */
isLocal: boolean;
/**
* The TLV encoded custom channel data records for this output, which might
* be set for custom channels.
*/
customChannelData: Uint8Array | string;
}

export interface ChannelCloseUpdate {
closingTxid: Uint8Array | string;
success: boolean;
/**
* The local channel close output. If the local channel balance was dust to
* begin with, this output will not be set.
*/
localCloseOutput: CloseOutput | undefined;
/**
* The remote channel close output. If the remote channel balance was dust
* to begin with, this output will not be set.
*/
remoteCloseOutput: CloseOutput | undefined;
/** Any additional outputs that might be added for custom channel types. */
additionalOutputs: CloseOutput[];
}

export interface CloseChannelRequest {
Expand Down Expand Up @@ -1991,6 +2035,8 @@ export interface PendingChannelsResponse_PendingChannel {
* impacts the channel's operation.
*/
memo: string;
/** Custom channel data that might be populated in custom channels. */
customChannelData: Uint8Array | string;
}

export interface PendingChannelsResponse_PendingOpenChannel {
Expand Down Expand Up @@ -2212,6 +2258,11 @@ export interface ChannelBalanceResponse {
pendingOpenLocalBalance: Amount | undefined;
/** Sum of channels pending remote balances. */
pendingOpenRemoteBalance: Amount | undefined;
/**
* Custom channel data that might be populated if there are custom channels
* present.
*/
customChannelData: Uint8Array | string;
}

export interface QueryRoutesRequest {
Expand Down Expand Up @@ -2507,6 +2558,16 @@ export interface Route {
totalFeesMsat: string;
/** The total amount in millisatoshis. */
totalAmtMsat: string;
/**
* The actual on-chain amount that was sent out to the first hop. This value is
* only different from the total_amt_msat field if this is a custom channel
* payment and the value transported in the HTLC is different from the BTC
* amount in the HTLC. If this value is zero, then this is an old payment that
* didn't have this value yet and can be ignored.
*/
firstHopAmountMsat: string;
/** Custom channel data that might be populated in custom channels. */
customChannelData: Uint8Array | string;
}

export interface NodeInfoRequest {
Expand Down Expand Up @@ -2666,6 +2727,11 @@ export interface ChanInfoRequest {
* output index for the channel.
*/
chanId: string;
/**
* The channel point of the channel in format funding_txid:output_index. If
* chan_id is specified, this field is ignored.
*/
chanPoint: string;
}

export interface NetworkInfoRequest {}
Expand Down Expand Up @@ -3006,6 +3072,17 @@ export interface Invoice {
* Note: Output only, don't specify for creating an invoice.
*/
ampInvoiceState: { [key: string]: AMPInvoiceState };
/**
* Signals that the invoice should include blinded paths to hide the true
* identity of the recipient.
*/
isBlinded: boolean;
/**
* Config values to use when creating blinded paths for this invoice. These
* can be used to override the defaults config values provided in by the
* global config. This field is only used if is_blinded is true.
*/
blindedPathConfig: BlindedPathConfig | undefined;
}

export enum Invoice_InvoiceState {
Expand All @@ -3026,6 +3103,30 @@ export interface Invoice_AmpInvoiceStateEntry {
value: AMPInvoiceState | undefined;
}

export interface BlindedPathConfig {
/**
* The minimum number of real hops to include in a blinded path. This doesn't
* include our node, so if the minimum is 1, then the path will contain at
* minimum our node along with an introduction node hop. If it is zero then
* the shortest path will use our node as an introduction node.
*/
minNumRealHops?: number | undefined;
/**
* The number of hops to include in a blinded path. This doesn't include our
* node, so if it is 1, then the path will contain our node along with an
* introduction node or dummy node hop. If paths shorter than NumHops is
* found, then they will be padded using dummy hops.
*/
numHops?: number | undefined;
/** The maximum number of blinded paths to select and add to an invoice. */
maxNumPaths?: number | undefined;
/**
* A list of node IDs of nodes that should not be used in any of our generated
* blinded paths.
*/
nodeOmissionList: Uint8Array | string[];
}

/** Details of an HTLC that paid to an invoice */
export interface InvoiceHTLC {
/** Short channel id over which the htlc was received. */
Expand All @@ -3050,6 +3151,8 @@ export interface InvoiceHTLC {
mppTotalAmtMsat: string;
/** Details relevant to AMP HTLCs, only populated if this is an AMP HTLC. */
amp: AMP | undefined;
/** Custom channel data that might be populated in custom channels. */
customChannelData: Uint8Array | string;
}

export interface InvoiceHTLC_CustomRecordsEntry {
Expand Down Expand Up @@ -3232,6 +3335,11 @@ export interface Payment {
*/
paymentIndex: string;
failureReason: PaymentFailureReason;
/**
* The custom TLV records that were sent to the first hop as part of the HTLC
* wire message for this payment.
*/
firstHopCustomRecords: { [key: string]: Uint8Array | string };
}

export enum Payment_PaymentStatus {
Expand All @@ -3252,6 +3360,11 @@ export enum Payment_PaymentStatus {
UNRECOGNIZED = 'UNRECOGNIZED'
}

export interface Payment_FirstHopCustomRecordsEntry {
key: string;
value: Uint8Array | string;
}

export interface HTLCAttempt {
/** The unique ID that is used for this attempt. */
attemptId: string;
Expand Down Expand Up @@ -3408,6 +3521,7 @@ export interface PayReq {
paymentAddr: Uint8Array | string;
numMsat: string;
features: { [key: number]: Feature };
blindedPaths: BlindedPaymentPath[];
}

export interface PayReq_FeaturesEntry {
Expand Down
Loading
Loading