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

Update BIP 78 Implementation to Match Protocol Changes #9

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DanGould
Copy link

@DanGould DanGould commented Jan 15, 2025

BIP 78 is still in draft, and was updated to permit a proposal having filled-in UTXO info in order to be in compliance with BIP 174 (PSBT). See: bitcoin/bips#1396

It has also been updated to allow mixed input scripts at the protocol level, which should be addressed in payjoin-client as well. See: bitcoin/bips#1605

I believe some of the dependencies are out of date so I ran into an issue when I tried to transpile and test, but I figure I should still post this to act as a way to track the update. Do dependencies need to be updated? Would @junderw be up for that prep work to get these updates in?

I am tracking all of the ecosystem updates here, where you may find some guidance for how to update based on the other implementations.

BIP 78 was updated to permit this behavior in order to be in compliance
with BIP 174 (PSBT).

See: bitcoin/bips#1396
@DanGould DanGould changed the title Update BIP 78 Chanages Update BIP 78 Implementation to Match Protocol Changes Jan 15, 2025
@junderw
Copy link
Member

junderw commented Jan 16, 2025

I ran into an issue when I tried to transpile and test

Can you post the error?

@DanGould
Copy link
Author

I've got a bunch of errors on PsbtTx{Input,Output} maps although I didn't update any dependencies. See details:

% npm test                                                                                                

[email protected] test
npm run build && npm run format:ci && npm run lint && npm run unit

[email protected] build
npm run clean && tsc -p tsconfig.json && npm run formatjs

[email protected] clean
rm -rf src

node_modules/bitcoinjs-lib/types/psbt.d.ts:2:96 - error TS2305: Module '"../../bip174/src/lib/interfaces"' has no exported member 'TransactionInput'.

2 import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
~~~~~~~~~~~~~~~~

node_modules/bitcoinjs-lib/types/psbt.d.ts:2:114 - error TS2305: Module '"../../bip174/src/lib/interfaces"' has no exported member 'TransactionOutput'.

2 import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
~~~~~~~~~~~~~~~~~

ts_src/client.ts:146:24 - error TS2339: Property 'index' does not exist on type 'PsbtTxInput'.

146 proposedTxIn.index,
~~~~~

ts_src/client.ts:153:34 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

153 if (input.originalTxIn.sequence !== proposedTxIn.sequence)
~~~~~~~~

ts_src/client.ts:153:60 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

153 if (input.originalTxIn.sequence !== proposedTxIn.sequence)
~~~~~~~~

ts_src/client.ts:160:28 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

160 if (proposedTxIn.sequence != null) {
~~~~~~~~

ts_src/client.ts:161:40 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

161 sequences.add(proposedTxIn.sequence);
~~~~~~~~

ts_src/client.ts:193:28 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

193 if (proposedTxIn.sequence != null) {
~~~~~~~~

ts_src/client.ts:194:40 - error TS2339: Property 'sequence' does not exist on type 'PsbtTxInput'.

194 sequences.add(proposedTxIn.sequence);
~~~~~~~~

ts_src/client.ts:236:63 - error TS2339: Property 'script' does not exist on type 'PsbtTxOutput'.

236 const isOriginalOutput = originalOutput.originalTxOut.script.equals(
~~~~~~

ts_src/client.ts:237:36 - error TS2339: Property 'script' does not exist on type 'PsbtTxOutput'.

237 payjoinPsbt.txOutputs[i].script,
~~~~~~

ts_src/client.ts:242:40 - error TS2339: Property 'script' does not exist on type 'PsbtTxOutput'.

242 originalOutput.originalTxOut.script.equals(this.paymentScript);
~~~~~~

ts_src/client.ts:250:27 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

250 proposedTxOut.value !== feeOutput.originalTxOut.value
~~~~~

ts_src/client.ts:250:61 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

250 proposedTxOut.value !== feeOutput.originalTxOut.value
~~~~~

ts_src/client.ts:253:39 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

253 feeOutput.originalTxOut.value - proposedTxOut.value;
~~~~~

ts_src/client.ts:253:61 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

253 feeOutput.originalTxOut.value - proposedTxOut.value;
~~~~~

ts_src/client.ts:278:42 - error TS2339: Property 'script' does not exist on type 'PsbtTxOutput'.

278 originalOutput.originalTxOut.script.equals(this.paymentScript)
~~~~~~

ts_src/client.ts:282:46 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

282 if (originalOutput.originalTxOut.value > proposedTxOut.value)
~~~~~

ts_src/client.ts:282:68 - error TS2339: Property 'value' does not exist on type 'PsbtTxOutput'.

282 if (originalOutput.originalTxOut.value > proposedTxOut.value)
~~~~~

ts_src/client.ts:298:28 - error TS2339: Property 'script' does not exist on type 'PsbtTxOutput'.

298 .originalTxOut.script.equals(this.paymentScript)
~~~~~~

ts_src/utils.ts:88:13 - error TS2339: Property 'index' does not exist on type 'PsbtTxInput'.

88 input.index === prevOutIndex
~~~~~

Found 21 errors.

I did read the bitcoinjs-lib/CONTRIBUTING.md typescript section which says the following,

Some rules regarding TypeScript:

  • Modify the typescript source code in an IDE that will give you warnings for transpile/lint errors.
  • Once you are done with the modifications, run npm run format then npm test

and I experience these errors after running npm test. I imagine, but am uncertain, that VSCode with JavaScript and TypeScript Nightly extension is sufficient to satisfy the first bullet.

My guess is that I've either got an environment issue with old dependencies, or that this library specifies an out of date bitcoinjs library that has experienced breaking changes that are automatically being applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants