Skip to content

Commit

Permalink
add support for updating a chain transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbosworth committed May 28, 2020
1 parent dfab943 commit e4a6878
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 88 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Versions

## 48.3.0

- `updateChainTransaction`: Add support for updating chain transaction label

## 48.2.0

- `broadcastChainTransaction`: Add support for transaction `description`
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ for `unlocker` methods.
- [subscribeToTransactions](#subscribeToTransactions) - Subscribe to chain tx
- [unauthenticatedLndGrpc](#unauthenticatedLndGrpc) - LND for locked lnd APIs
- [unlockWallet](#unlockWallet) - Unlock a locked lnd
- [updateChainTransaction](#updateChainTransaction) - Update a chain transaction
- [updateConnectedWatchtower](#updateConnectedWatchtower) - Update watchtower
- [updateRoutingFees](#updateRoutingFees) - Change routing fees
- [verifyBackup](#verifyBackup) - Verify a channel backup
Expand Down Expand Up @@ -5223,6 +5224,36 @@ const {lnd} = unauthenticatedLndGrpc({});
await unlockWallet({lnd, password: 'walletSecretPassword'});
```

### updateChainTransaction

Update an on-chain transaction record metadata

Requires LND built with `walletrpc` build tag

Requires `onchain:write` permission

This method is not supported in LND 0.10.1 and below

{
description: <Transaction Label String>
id: <Transaction Id Hex String>
lnd: <Authenticated LND API Object>
}

@returns via cbk or Promise

Example:

```node
const {getChainTransactions} = require('ln-service');

const {transactions} = await getChainTransactions({lnd});

const [{id}] = transactions;

await updateChainTransaction({id, lnd, description: 'First transaction'});
```

### updateConnectedWatchtower

Update a watchtower
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ const {subscribeToProbeForRoute} = require('lightning/lnd_methods');
const {subscribeToTransactions} = require('./lightning');
const {unauthenticatedLndGrpc} = require('lightning');
const {unlockWallet} = require('./unlocker');
const {updateChainTransaction} = require('lightning/lnd_methods');
const {updateConnectedWatchtower} = require('./tower_client');
const {updateRoutingFees} = require('./lightning');
const {verifyBackup} = require('./lightning');
Expand Down Expand Up @@ -214,6 +215,7 @@ module.exports = {
subscribeToTransactions,
unauthenticatedLndGrpc,
unlockWallet,
updateChainTransaction,
updateConnectedWatchtower,
updateRoutingFees,
verifyBackup,
Expand Down
139 changes: 55 additions & 84 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"express": "4.17.1",
"invoices": "1.0.2",
"is-base64": "1.1.0",
"lightning": "2.0.5",
"lightning": "2.0.6",
"macaroon": "3.0.4",
"morgan": "1.10.0",
"ws": "7.3.0"
Expand Down Expand Up @@ -60,5 +60,5 @@
"tower_server-integration-tests": "tap --no-coverage test/tower_serverrpc-integration/*.js",
"wallet-integration-tests": "tap --no-coverage test/walletrpc-integration/*.js"
},
"version": "48.2.0"
"version": "48.3.0"
}
6 changes: 4 additions & 2 deletions test/integration/test_open_channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ const {openChannel} = require('./../../');
const channelCapacityTokens = 1e6;
const defaultFee = 1e3;
const defaultVout = 0;
const format = 'p2wpkh';
const giftTokens = 1000;
const interval = 250;
const times = 100;
const txIdHexLength = 32 * 2;
const format = 'p2wpkh';

// Opening a channel should open a channel
test(`Open channel`, async ({end, equal}) => {
Expand All @@ -20,7 +22,7 @@ test(`Open channel`, async ({end, equal}) => {

const {address} = await createChainAddress({format, lnd});

const channelOpen = await asyncRetry({}, async () => {
const channelOpen = await asyncRetry({interval, times}, async () => {
return await openChannel({
lnd,
chain_fee_tokens_per_vbyte: defaultFee,
Expand Down
Loading

0 comments on commit e4a6878

Please sign in to comment.