Skip to content

Commit

Permalink
dep-up: bump node-dlc & add tx builder validation (#150)
Browse files Browse the repository at this point in the history
* dep-up: bump node-dlc & add tx builder validation

* docs: add changeset for batch tx builder validation
  • Loading branch information
matthewjablack authored Mar 16, 2024
1 parent 06792b4 commit e701ba6
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 96 deletions.
21 changes: 21 additions & 0 deletions .changeset/good-dragons-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
'@atomicfinance/bitcoin-dlc-provider': patch
'@atomicfinance/bitcoin-js-wallet-provider': patch
'@atomicfinance/bitcoin-wallet-provider': patch
'@atomicfinance/client': patch
'@atomicfinance/types': patch
'@atomicfinance/bitcoin-cfd-provider': patch
'@atomicfinance/bitcoin-esplora-api-provider': patch
'@atomicfinance/bitcoin-esplora-batch-api-provider': patch
'@atomicfinance/bitcoin-node-wallet-provider': patch
'@atomicfinance/bitcoin-rpc-provider': patch
'@atomicfinance/bitcoin-utils': patch
'@atomicfinance/crypto': patch
'@atomicfinance/errors': patch
'@atomicfinance/jsonrpc-provider': patch
'@atomicfinance/node-provider': patch
'@atomicfinance/provider': patch
'@atomicfinance/utils': patch
---

Bump node-dlc- to 0.23.1 and add node-dlc batch tx builder validation tests
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
],
"devDependencies": {
"@changesets/cli": "^2.22.0",
"@node-dlc/bitcoin": "0.23.0",
"@node-dlc/core": "0.23.0",
"@node-dlc/messaging": "0.23.0",
"@node-dlc/bitcoin": "0.23.1",
"@node-dlc/core": "0.23.1",
"@node-dlc/messaging": "0.23.1",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.172",
"@swc/register": "^0.1.10",
Expand Down
4 changes: 2 additions & 2 deletions packages/bitcoin-dlc-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@atomicfinance/provider": "^3.4.1",
"@atomicfinance/types": "^3.4.1",
"@atomicfinance/utils": "^3.4.1",
"@node-dlc/core": "0.23.0",
"@node-dlc/messaging": "0.23.0",
"@node-dlc/core": "0.23.1",
"@node-dlc/messaging": "0.23.1",
"@node-lightning/bitcoin": "0.26.1",
"@node-lightning/bufio": "0.26.1",
"@node-lightning/crypto": "0.26.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcoin-js-wallet-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@atomicfinance/types": "^3.4.1",
"@atomicfinance/utils": "^3.4.1",
"@babel/runtime": "^7.12.1",
"@node-dlc/core": "0.23.0",
"@node-dlc/core": "0.23.1",
"bip32": "^2.0.6",
"bip39": "^3.0.2",
"bitcoin-networks": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bitcoin-wallet-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@atomicfinance/bitcoin-utils": "^3.4.1",
"@atomicfinance/provider": "^3.4.1",
"@atomicfinance/types": "^3.4.1",
"@node-dlc/core": "0.23.0",
"@node-dlc/core": "0.23.1",
"bitcoin-networks": "^1.0.0",
"bitcoinjs-lib": "5.2.0",
"lodash": "^4.17.20",
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@atomicfinance/errors": "^3.4.1",
"@atomicfinance/provider": "^3.4.1",
"@atomicfinance/types": "^3.4.1",
"@node-dlc/messaging": "0.23.0",
"@node-dlc/messaging": "0.23.1",
"@node-lightning/bitcoin": "0.26.1",
"ajv": "^6.10.0",
"lodash": "^4.17.20"
Expand Down
2 changes: 1 addition & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"lint:fix": "../../node_modules/.bin/eslint --fix --ignore-path ../../.eslintignore -c ../../.eslintrc.js ."
},
"dependencies": {
"@node-dlc/messaging": "0.23.0",
"@node-dlc/messaging": "0.23.1",
"@node-lightning/bitcoin": "0.26.1",
"@node-lightning/noise": "0.26.1",
"lodash": "^4.17.20"
Expand Down
23 changes: 21 additions & 2 deletions tests/integration/dlc/custom-oracle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import 'mocha';

import { Value } from '@node-dlc/bitcoin';
import {
BatchDlcTxBuilder,
buildCustomStrategyOrderOffer,
buildRoundingIntervalsFromIntervals,
DualFundingTxFinalizer,
LinearPayout,
} from '@node-dlc/core';
import {
CetAdaptorSignaturesV0,
ContractDescriptorV0,
ContractDescriptorV1,
ContractInfoV0,
DigitDecompositionEventDescriptorV0,
Expand All @@ -18,16 +21,21 @@ import {
DlcParty,
DlcSign,
DlcTransactions,
EnumEventDescriptorV0,
FundingInputV0,
NegotiationFields,
NegotiationFieldsV0,
OracleAnnouncementV0,
OracleAttestationV0,
OracleEventV0,
OracleInfoV0,
PayoutFunctionV0,
RoundingIntervalsV0,
} from '@node-dlc/messaging';
import { Tx, TxOut } from '@node-lightning/bitcoin';
import { HashByteOrder, Sequence, Tx, TxOut } from '@node-lightning/bitcoin';
import { sha256 } from '@node-lightning/crypto';
import { math } from 'bip-schnorr';
import { BitcoinNetworks } from 'bitcoin-networks';
import { BitcoinNetworks, chainHashFromNetwork } from 'bitcoin-networks';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';

Expand Down Expand Up @@ -1315,11 +1323,22 @@ describe('Custom Strategy Oracle POC numdigits=21 split trades', () => {
dlcTxsList,
);

const txBuilder = new BatchDlcTxBuilder(
dlcOffers as DlcOfferV0[],
dlcAccepts.map((dlcAccept) => (dlcAccept as DlcAcceptV0).withoutSigs()),
);

// Ensure node-dlc tx builder builds identical transaction to cfd-dlc C++ implementation
const fundTxIdNodeDlc = txBuilder
.buildFundingTransaction()
.txId.toString(HashByteOrder.RPC);

const fundTxId = await bob.chain.sendRawTransaction(
fundTx.serialize().toString('hex'),
);

expect(fundTxId).to.be.a('string');
expect(fundTxId).to.equal(fundTxIdNodeDlc); // validates that node-dlc tx builder built identical tx

oracleAttestation = generateOracleAttestation(
outcome,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"transpileOnly": true,
"swc": true,
},
"exclude": ["node_modules", "**/*.spec.ts", "dist"]
"exclude": ["node_modules", "**/*.spec.ts", "dist"],
}
Loading

0 comments on commit e701ba6

Please sign in to comment.