Skip to content

Commit

Permalink
add support for routerrpc sendtoroute
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbosworth committed May 31, 2019
1 parent 240aae2 commit 25eb1fc
Show file tree
Hide file tree
Showing 90 changed files with 2,000 additions and 357 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Versions

## 38.1.0

- Add support for paying via routes in the routerrpc API.
- Add support for node color in getWalletInfo
- Add support for watching arbitrary output scripts when subscribing to address
- Add support for returning chain ids in getWalletInfo

## 38.0.0

### Breaking Changes
Expand Down
2 changes: 1 addition & 1 deletion accounting/get_accounting_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const asyncAuto = require('async/auto');
const asyncMapSeries = require('async/mapSeries');
const asyncUntil = require('async/until');
const {includes} = require('lodash');
const {returnResult} = require('asyncjs-util');
const {sortBy} = require('lodash');

const {getChainTransactions} = require('./../lightning');
Expand All @@ -13,7 +14,6 @@ const {getInvoices} = require('./../lightning');
const {getPayments} = require('./../lightning');
const {getPendingChannels} = require('./../lightning');
const harmonize = require('./harmonize');
const {returnResult} = require('./../async-util');

const earlyStartDate = '2017-08-24T08:57:37.000Z';
const largeLimit = 1e8;
Expand Down
4 changes: 3 additions & 1 deletion accounting/harmonize.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ const {Parser} = require('json2csv');

const {fields} = require('./harmony');

const {isArray} = Array;

/** Convert accounting records into Harmony CSV format
{
Expand All @@ -27,7 +29,7 @@ const {fields} = require('./harmony');
}
*/
module.exports = ({records}) => {
if (!Array.isArray(records)) {
if (!isArray(records)) {
throw new Error('ExpectedRecordsToConvertToHarmonyFormat');
}

Expand Down
6 changes: 0 additions & 6 deletions async-util/index.js

This file was deleted.

23 changes: 0 additions & 23 deletions async-util/return_result.js

This file was deleted.

2 changes: 1 addition & 1 deletion autopilot/get_autopilot.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const asyncAuto = require('async/auto');
const asyncMap = require('async/map');
const {flattenDeep} = require('lodash');
const {returnResult} = require('asyncjs-util');

const {externalType} = require('./constants');
const {maxScore} = require('./constants');
const {prefAttachType} = require('./constants');
const {returnResult} = require('./../async-util');
const {weightedType} = require('./constants');
const {wrongLnd} = require('./constants');

Expand Down
2 changes: 1 addition & 1 deletion autopilot/set_autopilot.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const asyncAuto = require('async/auto');
const {returnResult} = require('asyncjs-util');

const {externalType} = require('./constants');
const getAutopilot = require('./get_autopilot');
const {maxScore} = require('./constants');
const {returnResult} = require('./../async-util');
const {unknownHeuristicErrorMessage} = require('./constants');
const {wrongLnd} = require('./constants');

Expand Down
3 changes: 1 addition & 2 deletions backups/backups_from_snapshot.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const asyncAuto = require('async/auto');
const asyncEach = require('async/each');
const asyncMap = require('async/map');

const {returnResult} = require('./../async-util');
const {returnResult} = require('asyncjs-util');

const {isArray} = Array;

Expand Down
27 changes: 27 additions & 0 deletions bolt02/chain_id.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const {chains} = require('./ids');

/** Chain id for chain
{
chain: <Chain Name String>
network: <Network Type String>
}
@returns
{
[chain]: <Chain Id Hex String>
}
*/
module.exports = ({chain, network}) => {
if (!chain || !network) {
return {};
}

const id = chains[`${chain}${network}`];

if (!id) {
return {};
}

return {chain: Buffer.from(id, 'hex').reverse().toString('hex')};
};
10 changes: 10 additions & 0 deletions bolt02/ids.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"chains": {
"bitcoinmainnet": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"bitcoinregtest": "0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206",
"bitcointestnet": "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
"litecoinmainnet": "12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2",
"litecoinregtest": "530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9",
"litecointestnet": "4966625a4b2851d9fdee139e56211a0d88575f59ed816ff5e6a63deb4e3e29a0"
}
}
3 changes: 3 additions & 0 deletions bolt02/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const chainId = require('./chain_id');

module.exports = {chainId};
35 changes: 21 additions & 14 deletions chain/subscribe_to_chain_address.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const {dummyTxId} = require('./constants');

/** Subscribe to confirmation details about transactions sent to an address
One and only one chain address is required
One and only one chain address or output script is required
{
[bech32_address]: <Address String>
lnd: <Chain RPC LND gRPC API Object>
[min_confirmations]: <Minimum Confirmations Number>
[min_height]: <Minimum Transaction Inclusion Blockchain Height Number>
[output_script]: <Output Script Hex String>
[p2pkh_address]: <Address String>
[p2sh_address]: <Address String>
[transaction_id]: <Blockchain Transaction Id String>
Expand All @@ -35,30 +36,36 @@ const {dummyTxId} = require('./constants');
}
*/
module.exports = args => {
if (!args.bech32_address && !args.p2sh_address && !args.p2pkh_address) {
throw new Error('ExpectedChainAddressToSubscribeForConfirmationEvents');
let outputScript = args.output_script;

if (!args.output_script) {
if (!args.bech32_address && !args.p2sh_address && !args.p2pkh_address) {
throw new Error('ExpectedChainAddressToSubscribeForConfirmationEvents');
}

const {script} = scriptFromChainAddress({
bech32_address: args.bech32_address,
p2pkh_address: args.p2pkh_address,
p2sh_address: args.p2sh_address,
});

if (!script) {
throw new Error('ExpectedRecognizedAddressFormatToWatchForScript');
}

outputScript = script;
}

if (!args.lnd || !args.lnd.chain) {
throw new Error('ExpectedLndGrpcApiToSubscribeToChainTransaction');
}

const {script} = scriptFromChainAddress({
bech32_address: args.bech32_address,
p2pkh_address: args.p2pkh_address,
p2sh_address: args.p2sh_address,
});

if (!script) {
throw new Error('ExpectedRecognizedAddressFormatToWatchForScript');
}

const eventEmitter = new EventEmitter();

const sub = args.lnd.chain.registerConfirmationsNtfn({
height_hint: args.min_height || 0,
num_confs: args.min_confirmations || 1,
script: Buffer.from(script, 'hex'),
script: Buffer.from(outputScript, 'hex'),
txid: Buffer.from(args.transaction_id || dummyTxId, 'hex'),
});

Expand Down
16 changes: 16 additions & 0 deletions getNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ const {getNode} = require('./');
alias: <Node Alias String>
capacity: <Node Total Capacity Tokens Number>
channel_count: <Known Node Channels Number>
[channels]: [{
capacity: <Maximum Tokens Number>
id: <Standard Format Channel Id String>
policies: [{
[base_fee_mtokens]: <Base Fee Millitokens String>
[cltv_delta]: <Locktime Delta Number>
[fee_rate]: <Fees Charged Per Million Tokens Number>
[is_disabled]: <Channel Is Disabled Bool>
[max_htlc_mtokens]: <Maximum HTLC Millitokens Value String>
[min_htlc_mtokens]: <Minimum HTLC Millitokens Value String>
public_key: <Node Public Key String>
}]
transaction_id: <Transaction Id Hex String>
transaction_vout: <Transaction Output Index Number>
[updated_at]: <Channel Last Updated At ISO 8601 Date String>
}]
color: <RGB Hex Color String>
sockets: [{
socket: <Host and Port String>
Expand Down
3 changes: 2 additions & 1 deletion getWalletInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ const {getWalletInfo} = require('./');
{
active_channels_count: <Active Channels Count Number>
alias: <Node Alias String>
[chains]: [<Chain Id Hex String>]
[color]: <Node Color String>
current_block_hash: <Best Chain Hash Hex String>
current_block_height: <Best Chain Height Number>
is_synced_to_chain: <Is Synced To Chain Bool>
is_testnet: <Using Testnet Bool>
latest_block_at: <Latest Known Block At Date String>
peers_count: <Peer Count Number>
pending_channels_count: <Pending Channels Count Number>
Expand Down
Loading

0 comments on commit 25eb1fc

Please sign in to comment.