lightning 10.17.0 → 10.19.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/CHANGELOG.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # Versions
2
2
 
3
+ ## 10.19.0
4
+
5
+ - `createInvoice`: add `is_encrypting_routes` to enable blinded paths feature
6
+
7
+ - `pay`, `subscribeToPastPayment`, `subscribeToPayViaDetails`,
8
+ `subscribeToPayViaRequest`, `subscribeToPayments`: Add `is_canceled` for
9
+ when the payment loop was explicitly canceled.
10
+
11
+ ## 10.18.0
12
+
13
+ - `getMinimumRelayFee`: Add method to get the chain backend minimum relay fee
14
+
3
15
  ## 10.17.0
4
16
 
5
17
  - `getFeeRates`: Add support for `inbound_base_discount_mtokens`,
6
- 'inbound_rate_discount` for inbound fee policy discounts
18
+ `inbound_rate_discount` for inbound fee policy discounts
7
19
 
8
20
  ## 10.16.1
9
21
 
package/README.md CHANGED
@@ -201,6 +201,8 @@ variables set:
201
201
  List out master seed derived extended public keys and derivation paths.
202
202
  - [getMethods](https://github.com/alexbosworth/ln-service#getmethods): List RPC methods and
203
203
  permissions required to use them.
204
+ - [getMinimumRelayFee](https://github.com/alexbosworth/ln-service#getminimumrelayfee):
205
+ Get the minimum relayable fee for publishing a chain transaction
204
206
  - [getNetworkCentrality](https://github.com/alexbosworth/ln-service#getnetworkcentrality):
205
207
  Calculate the graph centrality score of a node.
206
208
  - [getNetworkGraph](https://github.com/alexbosworth/ln-service#getnetworkgraph): List all graph
@@ -1190,9 +1190,8 @@ message SendCoinsRequest {
1190
1190
  int64 sat_per_byte = 5 [deprecated = true];
1191
1191
 
1192
1192
  /*
1193
- If set, then the amount field will be ignored, and lnd will attempt to
1194
- send all the coins under control of the internal wallet to the specified
1195
- address.
1193
+ If set, the amount field should be unset. It indicates lnd will send all
1194
+ wallet coins or all selected coins to the specified address.
1196
1195
  */
1197
1196
  bool send_all = 6;
1198
1197
 
@@ -1208,6 +1207,9 @@ message SendCoinsRequest {
1208
1207
 
1209
1208
  // The strategy to use for selecting coins.
1210
1209
  CoinSelectionStrategy coin_selection_strategy = 10;
1210
+
1211
+ // A list of selected outpoints as inputs for the transaction.
1212
+ repeated OutPoint outpoints = 11;
1211
1213
  }
1212
1214
  message SendCoinsResponse {
1213
1215
  // The transaction ID of the transaction
@@ -3836,6 +3838,48 @@ message Invoice {
3836
3838
  Note: Output only, don't specify for creating an invoice.
3837
3839
  */
3838
3840
  map<string, AMPInvoiceState> amp_invoice_state = 28;
3841
+
3842
+ /*
3843
+ Signals that the invoice should include blinded paths to hide the true
3844
+ identity of the recipient.
3845
+ */
3846
+ bool is_blinded = 29;
3847
+
3848
+ /*
3849
+ Config values to use when creating blinded paths for this invoice. These
3850
+ can be used to override the defaults config values provided in by the
3851
+ global config. This field is only used if is_blinded is true.
3852
+ */
3853
+ BlindedPathConfig blinded_path_config = 30;
3854
+ }
3855
+
3856
+ message BlindedPathConfig {
3857
+ /*
3858
+ The minimum number of real hops to include in a blinded path. This doesn't
3859
+ include our node, so if the minimum is 1, then the path will contain at
3860
+ minimum our node along with an introduction node hop. If it is zero then
3861
+ the shortest path will use our node as an introduction node.
3862
+ */
3863
+ optional uint32 min_num_real_hops = 1;
3864
+
3865
+ /*
3866
+ The number of hops to include in a blinded path. This doesn't include our
3867
+ node, so if it is 1, then the path will contain our node along with an
3868
+ introduction node or dummy node hop. If paths shorter than NumHops is
3869
+ found, then they will be padded using dummy hops.
3870
+ */
3871
+ optional uint32 num_hops = 2;
3872
+
3873
+ /*
3874
+ The maximum number of blinded paths to select and add to an invoice.
3875
+ */
3876
+ optional uint32 max_num_paths = 3;
3877
+
3878
+ /*
3879
+ A list of node IDs of nodes that should not be used in any of our generated
3880
+ blinded paths.
3881
+ */
3882
+ repeated bytes node_omission_list = 4;
3839
3883
  }
3840
3884
 
3841
3885
  enum InvoiceHTLCState {
@@ -4044,6 +4088,11 @@ enum PaymentFailureReason {
4044
4088
  Insufficient local balance.
4045
4089
  */
4046
4090
  FAILURE_REASON_INSUFFICIENT_BALANCE = 5;
4091
+
4092
+ /*
4093
+ The payment was canceled.
4094
+ */
4095
+ FAILURE_REASON_CANCELED = 6;
4047
4096
  }
4048
4097
 
4049
4098
  message Payment {
@@ -4289,6 +4338,7 @@ message PayReq {
4289
4338
  bytes payment_addr = 11;
4290
4339
  int64 num_msat = 12;
4291
4340
  map<uint32, Feature> features = 13;
4341
+ repeated BlindedPaymentPath blinded_paths = 14;
4292
4342
  }
4293
4343
 
4294
4344
  enum FeatureBit {
@@ -839,6 +839,9 @@ message EstimateFeeResponse {
839
839
  confirmation target in the request.
840
840
  */
841
841
  int64 sat_per_kw = 1;
842
+
843
+ // The current minimum relay fee based on our chain backend in sat/kw.
844
+ int64 min_relay_fee_sat_per_kw = 2;
842
845
  }
843
846
 
844
847
  enum WitnessType {
package/index.js CHANGED
@@ -61,6 +61,7 @@ const {getInvoices} = require('./lnd_methods');
61
61
  const {getLockedUtxos} = require('./lnd_methods');
62
62
  const {getMasterPublicKeys} = require('./lnd_methods');
63
63
  const {getMethods} = require('./lnd_methods');
64
+ const {getMinimumRelayFee} = require('./lnd_methods');
64
65
  const {getNetworkCentrality} = require('./lnd_methods');
65
66
  const {getNetworkGraph} = require('./lnd_methods');
66
67
  const {getNetworkInfo} = require('./lnd_methods');
@@ -221,6 +222,7 @@ module.exports = {
221
222
  getLockedUtxos,
222
223
  getMasterPublicKeys,
223
224
  getMethods,
225
+ getMinimumRelayFee,
224
226
  getNetworkCentrality,
225
227
  getNetworkGraph,
226
228
  getNetworkInfo,
@@ -60,6 +60,7 @@ const {getInvoices} = require('./invoices');
60
60
  const {getLockedUtxos} = require('./onchain');
61
61
  const {getMasterPublicKeys} = require('./onchain');
62
62
  const {getMethods} = require('./info');
63
+ const {getMinimumRelayFee} = require('./onchain');
63
64
  const {getNetworkCentrality} = require('./info');
64
65
  const {getNetworkGraph} = require('./info');
65
66
  const {getNetworkInfo} = require('./info');
@@ -219,6 +220,7 @@ module.exports = {
219
220
  getLockedUtxos,
220
221
  getMasterPublicKeys,
221
222
  getMethods,
223
+ getMinimumRelayFee,
222
224
  getNetworkCentrality,
223
225
  getNetworkGraph,
224
226
  getNetworkInfo,
@@ -26,6 +26,8 @@ export type GetWalletInfoResult = {
26
26
  }[];
27
27
  /** Is Synced To Chain */
28
28
  is_synced_to_chain: boolean;
29
+ /** Is Synced To Network Graph */
30
+ is_synced_to_graph?: boolean;
29
31
  /** Latest Known Block At Date */
30
32
  latest_block_at: string;
31
33
  /** Peer Count */
@@ -34,6 +36,8 @@ export type GetWalletInfoResult = {
34
36
  pending_channels_count: number;
35
37
  /** Public Key */
36
38
  public_key: string;
39
+ /** The URIs of the Node */
40
+ uris?: string[];
37
41
  /** Version String */
38
42
  version: string;
39
43
  };
@@ -31,6 +31,7 @@ const type = 'default';
31
31
  [description]: <Invoice Description String>
32
32
  [description_hash]: <Hashed Description of Payment Hex String>
33
33
  [expires_at]: <Expires At ISO 8601 Date String>
34
+ [is_encrypting_routes]: <Use Blinded Paths For Inbound Routes Bool>
34
35
  [is_fallback_included]: <Is Fallback Address Included Bool>
35
36
  [is_fallback_nested]: <Is Fallback Address Nested Bool>
36
37
  [is_including_private_channels]: <Invoice Includes Private Channels Bool>
@@ -161,6 +162,7 @@ module.exports = (args, cbk) => {
161
162
  description_hash: hexAsBuffer(args.description_hash),
162
163
  expiry: !expiryMs ? defaultExpirySec : round(expiryMs / msPerSec),
163
164
  fallback_addr: fallbackAddress,
165
+ is_blinded: !!args.is_encrypting_routes,
164
166
  memo: args.description,
165
167
  private: !!args.is_including_private_channels,
166
168
  r_preimage: preimage || undefined,
@@ -39,6 +39,7 @@ const {returnResult} = require('asyncjs-util');
39
39
  tokens: <Total Tokens Paid Rounded Down Number>
40
40
  }
41
41
  [failed]: {
42
+ is_canceled: <Payment Canceled Bool>
42
43
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
43
44
  is_invalid_payment: <Failed Due to Invalid Payment Bool>
44
45
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -114,6 +115,10 @@ module.exports = ({confirmed, failed}, cbk) => {
114
115
  return cbk();
115
116
  }
116
117
 
118
+ if (!!failed.is_canceled) {
119
+ return cbk([503, 'PaymentExecutionCanceled']);
120
+ }
121
+
117
122
  if (!!failed.is_insufficient_balance) {
118
123
  return cbk([503, 'InsufficientBalanceToAttemptPayment']);
119
124
  }
@@ -78,6 +78,7 @@ const unknownServiceErr = 'unknown service verrpc.Versioner';
78
78
  @event 'failed'
79
79
  {
80
80
  id: <Payment Hash Hex String>
81
+ is_canceled: <Payment Canceled Bool>
81
82
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
82
83
  is_invalid_payment: <Failed Due to Payment Rejected At Destination Bool>
83
84
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -128,6 +128,7 @@ const unsupportedFeatures = [30, 31];
128
128
  @event 'failed'
129
129
  {
130
130
  id: <Payment Hash Hex String>
131
+ is_canceled: <Payment Canceled Bool>
131
132
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
132
133
  is_invalid_payment: <Failed Due to Invalid Payment Bool>
133
134
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -98,6 +98,7 @@ const type = 'router';
98
98
  @event 'failed'
99
99
  {
100
100
  id: <Payment Hash Hex String>
101
+ is_canceled: <Payment Canceled Bool>
101
102
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
102
103
  is_invalid_payment: <Failed Due to Invalid Payment Bool>
103
104
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -78,6 +78,7 @@ const type = 'router';
78
78
  @event 'failed'
79
79
  {
80
80
  id: <Payment Hash Hex String>
81
+ is_canceled: <Payment Canceled Bool>
81
82
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
82
83
  is_invalid_payment: <Failed Due to Invalid Payment Bool>
83
84
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -64,6 +64,7 @@ const type = 'router';
64
64
  @event 'failed'
65
65
  {
66
66
  id: <Payment Hash Hex String>
67
+ is_canceled: <Payment Canceled Bool>
67
68
  is_insufficient_balance: <Failed Due To Lack of Balance Bool>
68
69
  is_invalid_payment: <Failed Due to Payment Rejected At Destination Bool>
69
70
  is_pathfinding_timeout: <Failed Due to Pathfinding Timeout Bool>
@@ -0,0 +1,25 @@
1
+ import type {
2
+ AuthenticatedLightningArgs,
3
+ AuthenticatedLightningMethod,
4
+ } from '../../typescript';
5
+
6
+ export type GetMinimumRelayFeeArgs = AuthenticatedLightningArgs;
7
+
8
+ export interface GetMinimumRelayFeeResult {
9
+ /** Minimum Relayable Tokens Per Virtual Byte Number */
10
+ tokens_per_vbyte: number;
11
+ }
12
+
13
+ /**
14
+ * Get the current minimum relay fee for the chain backend
15
+ *
16
+ * Requires LND built with `walletrpc` tag
17
+ *
18
+ * Requires `onchain:read` permission
19
+ *
20
+ * This method is not supported on LND 0.18.2 and below
21
+ */
22
+ export const getMinimumRelayFee: AuthenticatedLightningMethod<
23
+ GetMinimumRelayFeeArgs,
24
+ GetMinimumRelayFeeResult
25
+ >;
@@ -0,0 +1,66 @@
1
+ const asyncAuto = require('async/auto');
2
+ const {returnResult} = require('asyncjs-util');
3
+
4
+ const {isLnd} = require('./../../lnd_requests');
5
+
6
+ const method = 'estimateFee';
7
+ const target = 6;
8
+ const type = 'wallet';
9
+ const weightPerKWeight = 1e3;
10
+ const weightPerVByte = 4;
11
+
12
+ /** Get the current minimum relay fee for the chain backend
13
+
14
+ Requires LND built with `walletrpc` tag
15
+
16
+ Requires `onchain:read` permission
17
+
18
+ This method is not supported on LND 0.18.2 and below
19
+
20
+ {
21
+ lnd: <Authenticated LND API Object>
22
+ }
23
+
24
+ @returns via cbk or Promise
25
+ {
26
+ tokens_per_vbyte: <Minimum Relayable Tokens Per Virtual Byte Number>
27
+ }
28
+ */
29
+ module.exports = (args, cbk) => {
30
+ return new Promise((resolve, reject) => {
31
+ return asyncAuto({
32
+ // Check arguments
33
+ validate: cbk => {
34
+ if (!isLnd({method, type, lnd: args.lnd})) {
35
+ return cbk([400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate']);
36
+ }
37
+
38
+ return cbk();
39
+ },
40
+
41
+ // Get the minimum relayable fee rate
42
+ getRate: ['validate', ({}, cbk) => {
43
+ return args.lnd[type][method]({conf_target: target}, (err, res) => {
44
+ if (!!err) {
45
+ return cbk([503, 'UnexpectedErrorGettingMinRateFromLnd', {err}]);
46
+ }
47
+
48
+ if (!res) {
49
+ return cbk([503, 'ExpectedResponseForMinFeeRateRequest']);
50
+ }
51
+
52
+ if (!res.min_relay_fee_sat_per_kw) {
53
+ return cbk([503, 'ExpectedMinPerKwResponseForMinFeeRateRequest']);
54
+ }
55
+
56
+ const minPerKw = Number(res.min_relay_fee_sat_per_kw);
57
+
58
+ const minPerVbyte = minPerKw * weightPerVByte / weightPerKWeight;
59
+
60
+ return cbk(null, {tokens_per_vbyte: minPerVbyte});
61
+ });
62
+ }],
63
+ },
64
+ returnResult({reject, resolve, of: 'getRate'}, cbk));
65
+ });
66
+ };
@@ -15,6 +15,7 @@ export * from './get_chain_transaction';
15
15
  export * from './get_chain_transactions';
16
16
  export * from './get_locked_utxos';
17
17
  export * from './get_master_public_keys';
18
+ export * from './get_minimum_relay_fee';
18
19
  export * from './get_pending_chain_balance';
19
20
  export * from './get_pending_sweeps';
20
21
  export * from './get_sweep_transactions';
@@ -15,6 +15,7 @@ const getChainTransaction = require('./get_chain_transaction');
15
15
  const getChainTransactions = require('./get_chain_transactions');
16
16
  const getLockedUtxos = require('./get_locked_utxos');
17
17
  const getMasterPublicKeys = require('./get_master_public_keys');
18
+ const getMinimumRelayFee = require('./get_minimum_relay_fee');
18
19
  const getPendingChainBalance = require('./get_pending_chain_balance');
19
20
  const getPendingSweeps = require('./get_pending_sweeps');
20
21
  const getSweepTransactions = require('./get_sweep_transactions');
@@ -59,6 +60,7 @@ module.exports = {
59
60
  getChainTransactions,
60
61
  getLockedUtxos,
61
62
  getMasterPublicKeys,
63
+ getMinimumRelayFee,
62
64
  getPendingChainBalance,
63
65
  getPendingSweeps,
64
66
  getSweepTransactions,
@@ -29,6 +29,10 @@ const unconfirmedConfCount = 0;
29
29
  address: <Destination Chain Address String>
30
30
  [description]: <Transaction Label String>
31
31
  [fee_tokens_per_vbyte]: <Chain Fee Tokens Per Virtual Byte Number>
32
+ [inputs]: [{
33
+ transaction_id: <Unspent Transaction Id Hex String>
34
+ transaction_vout: <Unspent Transaction Output Index Number>
35
+ }]
32
36
  [is_send_all]: <Send All Funds Bool>
33
37
  lnd: <Authenticated LND API Object>
34
38
  [log]: <Log Function>
@@ -29,6 +29,7 @@
29
29
  },
30
30
  "defaultChannelType": "UNKNOWN_COMMITMENT_TYPE",
31
31
  "failureReason": {
32
+ "canceled": "FAILURE_REASON_CANCELED",
32
33
  "invalid_payment": "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS",
33
34
  "insufficient_balance": "FAILURE_REASON_INSUFFICIENT_BALANCE",
34
35
  "pathfinding_timeout_failed": "FAILURE_REASON_TIMEOUT",
@@ -14,11 +14,12 @@ const is256Hex = n => !!n && /^[0-9A-F]{64}$/i.test(n);
14
14
 
15
15
  @returns
16
16
  {
17
- id: <Payment Hash Hex String>
18
- is_insufficient_balance: <Payment Failed Due to Insufficient Balance Bool>
19
- is_invalid_payment: <Payment Failed Due to Invalid Details Rejection Bool>
20
- is_pathfinding_timeout: <Failure Due To Pathfinding Timeout Failure Bool>
21
- is_route_not_found: <Failure Due to No Route To Destination Found Bool>
17
+ id: <Payment Hash Hex String>
18
+ is_canceled: <Payment Was Canceled Bool>
19
+ is_insufficient_balance: <Payment Failed Due to Insufficient Balance Bool>
20
+ is_invalid_payment: <Payment Failed Due to Invalid Details Rejection Bool>
21
+ is_pathfinding_timeout: <Failure Due To Pathfinding Timeout Failure Bool>
22
+ is_route_not_found: <Failure Due to No Route To Destination Found Bool>
22
23
  }
23
24
  */
24
25
  module.exports = payment => {
@@ -30,6 +31,7 @@ module.exports = payment => {
30
31
 
31
32
  return {
32
33
  id: payment.payment_hash,
34
+ is_canceled: state === failureReason.canceled,
33
35
  is_insufficient_balance: state === failureReason.insufficient_balance,
34
36
  is_invalid_payment: state === failureReason.invalid_payment,
35
37
  is_pathfinding_timeout: state === failureReason.pathfinding_timeout_failed,
@@ -15,6 +15,8 @@ const outpointDivider = ':';
15
15
  chan_id: <Numeric Format Channel Id String>
16
16
  channel_point: <Channel Funding Outpoint String>
17
17
  fee_per_mil: <Millitokens Per Million Fee Rate String>
18
+ inbound_base_fee_msat: <Inbound Base Fee Millitokens Number>
19
+ inbound_fee_per_mil: <Inbound Fee Rate PPM Number>
18
20
  }
19
21
 
20
22
  @returns
package/package.json CHANGED
@@ -9,10 +9,10 @@
9
9
  "dependencies": {
10
10
  "@grpc/grpc-js": "1.11.1",
11
11
  "@grpc/proto-loader": "0.7.13",
12
- "@types/node": "22.1.0",
12
+ "@types/node": "22.5.0",
13
13
  "@types/request": "2.48.12",
14
14
  "@types/ws": "8.5.12",
15
- "async": "3.2.5",
15
+ "async": "3.2.6",
16
16
  "asyncjs-util": "1.2.12",
17
17
  "bitcoinjs-lib": "6.1.6",
18
18
  "bn.js": "5.2.1",
@@ -22,7 +22,7 @@
22
22
  "invoices": "3.0.0",
23
23
  "psbt": "3.0.0",
24
24
  "tiny-secp256k1": "2.2.3",
25
- "type-fest": "4.23.0"
25
+ "type-fest": "4.25.0"
26
26
  },
27
27
  "description": "Lightning Network client library",
28
28
  "devDependencies": {
@@ -45,7 +45,7 @@
45
45
  "url": "https://github.com/alexbosworth/lightning.git"
46
46
  },
47
47
  "scripts": {
48
- "test": "npx nyc@15.1.0 node --experimental-test-coverage --test && npm run test:types",
48
+ "test": "npx nyc@17.0.0 node --experimental-test-coverage --test && npm run test:types",
49
49
  "test:types": "tsd",
50
50
  "unit-tests": "node --test && npm run test:types"
51
51
  },
@@ -53,5 +53,5 @@
53
53
  "directory": "test/typescript"
54
54
  },
55
55
  "types": "index.d.ts",
56
- "version": "10.17.0"
56
+ "version": "10.19.0"
57
57
  }
@@ -0,0 +1,71 @@
1
+ const {rejects} = require('node:assert').strict;
2
+ const {strictEqual} = require('node:assert').strict;
3
+ const test = require('node:test');
4
+
5
+ const {getMinimumRelayFee} = require('./../../../lnd_methods');
6
+
7
+ const tests = [
8
+ {
9
+ args: {},
10
+ description: 'LND is required',
11
+ error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
12
+ },
13
+ {
14
+ args: {lnd: {}},
15
+ description: 'LND with wallet object is required',
16
+ error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
17
+ },
18
+ {
19
+ args: {lnd: {wallet: {}}},
20
+ description: 'LND with estimateFee method is required',
21
+ error: [400, 'ExpecteAuthenticatedLndToGetMinRelayFeeRate'],
22
+ },
23
+ {
24
+ args: {
25
+ lnd: {wallet: {estimateFee: ({}, cbk) => cbk('err')}},
26
+ },
27
+ description: 'Unexpected errors are passed back',
28
+ error: [503, 'UnexpectedErrorGettingMinRateFromLnd', {err: 'err'}],
29
+ },
30
+ {
31
+ args: {
32
+ lnd: {wallet: {estimateFee: ({}, cbk) => cbk()}},
33
+ },
34
+ description: 'A response is expected',
35
+ error: [503, 'ExpectedResponseForMinFeeRateRequest'],
36
+ },
37
+ {
38
+ args: {
39
+ lnd: {wallet: {estimateFee: ({}, cbk) => cbk(null, {})}},
40
+ },
41
+ description: 'A response is expected',
42
+ error: [503, 'ExpectedMinPerKwResponseForMinFeeRateRequest'],
43
+ },
44
+ {
45
+ args: {
46
+ lnd: {
47
+ wallet: {
48
+ estimateFee: ({}, cbk) => cbk(null, {
49
+ min_relay_fee_sat_per_kw: '250',
50
+ }),
51
+ },
52
+ },
53
+ },
54
+ description: 'Minimum tokens per vbyte are returned',
55
+ expected: {tokens_per_vbyte: 1},
56
+ },
57
+ ];
58
+
59
+ tests.forEach(({args, description, error, expected}) => {
60
+ return test(description, async () => {
61
+ if (!!error) {
62
+ await rejects(getMinimumRelayFee(args), error, 'Got expected error');
63
+ } else {
64
+ const res = await getMinimumRelayFee(args);
65
+
66
+ strictEqual(res.tokens_per_vbyte, expected.tokens_per_vbyte, 'Got rate');
67
+ }
68
+
69
+ return;
70
+ });
71
+ });
@@ -9,6 +9,7 @@ const id = Buffer.alloc(32).toString('hex')
9
9
  const makeExpected = overrides => {
10
10
  const expected = {
11
11
  id,
12
+ is_canceled: false,
12
13
  is_insufficient_balance: false,
13
14
  is_invalid_payment: false,
14
15
  is_pathfinding_timeout: false,
@@ -53,6 +54,14 @@ const tests = [
53
54
  description: 'Timeout is mapped',
54
55
  expected: makeExpected({is_pathfinding_timeout: true}),
55
56
  },
57
+ {
58
+ args: {
59
+ failure_reason: 'FAILURE_REASON_CANCELED',
60
+ payment_hash: id,
61
+ },
62
+ description: 'Cancel is mapped',
63
+ expected: makeExpected({is_canceled: true}),
64
+ },
56
65
  {
57
66
  args: {payment_hash: undefined},
58
67
  description: 'A payment hash is expected',
@@ -72,6 +72,23 @@ const tests = [
72
72
  transaction_vout: 0,
73
73
  },
74
74
  },
75
+ {
76
+ args: makeArgs({
77
+ inbound_base_fee_msat: -1,
78
+ inbound_fee_per_mil: -1,
79
+ }),
80
+ description: 'RPC channel fees are mapped to inverse channel fees',
81
+ expected: {
82
+ base_fee: 0,
83
+ base_fee_mtokens: '1',
84
+ fee_rate: 0,
85
+ id: '0x0x1',
86
+ inbound_base_discount_mtokens: '1',
87
+ inbound_rate_discount: 1,
88
+ transaction_id: Buffer.alloc(32).toString('hex'),
89
+ transaction_vout: 0,
90
+ },
91
+ },
75
92
  ];
76
93
 
77
94
  tests.forEach(({args, description, error, expected}) => {