-
Notifications
You must be signed in to change notification settings - Fork 0
[BTC] Tx crafting #60
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
041e420
Cosmos improvements & bugfixes (#59)
h-adamik 6c1781d
Update Providers Doc
github-actions[bot] ac24a9d
EVM family: switch default transaction format from json to hex
h-adamik 294e452
DEBUG LOG, TO BE REVERTED
h-adamik 132abf0
DEBUG LOG, TO BE REVERTED
h-adamik e19dc5b
Revert "DEBUG LOG, TO BE REVERTED"
h-adamik 9b6ba0d
Revert "DEBUG LOG, TO BE REVERTED"
h-adamik 604312b
Change dYdX node
h-adamik 4db7c3f
Update Providers Doc
github-actions[bot] 260198c
Revert "fix: remove useless type guard of multiRecipientTx
regnarock 82885d1
feat: Adds simple TX crafting
regnarock 5cbb6bf
R.I.P original test-app
h-adamik 423f4a8
[ADV-280] ADV fix parity (#62)
henri-ly 519e2cc
Complete Cosmos staking implementation (#61)
h-adamik b7d714c
chore: code quality
regnarock 6819ac4
feat: adds support for useMaxAmount
regnarock 0f8f760
fix: patch package.lock version
regnarock e66443c
Merge branch 'main' into feat/btc_data_and_api
regnarock 334ff60
Merge branch 'feat/btc_data_and_api' into btc_tx_crafting
regnarock 1b128db
Merge branch 'feat/btc_balances' into btc_tx_crafting
regnarock b00e97e
Update OpenAPI JSON docs
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| diff --git a/index.d.ts b/index.d.ts | ||
| new file mode 100644 | ||
| index 0000000..20cc98a | ||
| --- /dev/null | ||
| +++ b/index.d.ts | ||
| @@ -0,0 +1,48 @@ | ||
| +// Declare the main coinselect module | ||
| +declare module "coinselect" { | ||
| + export interface UTXO { | ||
| + txid: string | Buffer; | ||
| + vout: number; | ||
| + value: number; | ||
| + nonWitnessUtxo?: Buffer; | ||
| + witnessUtxo?: { | ||
| + script: Buffer; | ||
| + value: number; | ||
| + }; | ||
| + } | ||
| + | ||
| + export type Target = | ||
| + | { | ||
| + address: string; | ||
| + value: number; | ||
| + } | ||
| + | { | ||
| + address: string; | ||
| + } | ||
| + | { | ||
| + value: number; | ||
| + }; | ||
| + | ||
| + export interface SelectedUTXO { | ||
| + inputs?: UTXO[]; | ||
| + outputs?: Target[]; | ||
| + fee: number; | ||
| + } | ||
| + | ||
| + export default function coinSelect( | ||
| + utxos: UTXO[], | ||
| + outputs: Target[], | ||
| + feeRate: number | ||
| + ): SelectedUTXO; | ||
| +} | ||
| + | ||
| +// Declare the coinselect/split module | ||
| +declare module "coinselect/split.js" { | ||
| + import { UTXO, Target, SelectedUTXO } from "coinselect"; | ||
| + | ||
| + export default function split( | ||
| + utxos: UTXO[], | ||
| + outputs: Target[], | ||
| + feeRate: number | ||
| + ): SelectedUTXO; | ||
| +} | ||
| diff --git a/package.json b/package.json | ||
| index 6cdef00..337bf4f 100644 | ||
| --- a/package.json | ||
| +++ b/package.json | ||
| @@ -31,6 +31,7 @@ | ||
| "utils.js" | ||
| ], | ||
| "main": "index.js", | ||
| + "types": "index.d.ts", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/bitcoinjs/coinselect.git" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| # Why this patch | ||
|
|
||
| The library `coinselect.js` is manipulating important and low level objects, it seems important to make sure we don't just send any information to it. | ||
| Because the lib is only published in NPM without its types ([because the maintainer doesnt trust NPM](https://github.com/bitcoinjs/coinselect/pull/77#issuecomment-1676430774)), I've patched the lib using their own type definition [their own definitions](https://github.com/bitcoinjs/coinselect/blob/master/index.d.ts), modified to actually reflect the lib's bahaviour. | ||
|
|
||
|
|
||
| # How to maintain the patch | ||
|
|
||
| Create a temporary copy of the library to patch | ||
| ```bash | ||
| pnpm patch | ||
| ``` | ||
|
|
||
| You now have access to a similar folder as: `/private/var/folders/yn/k6gkp3pd7fq4dn71mw1yb8qh0000gn/T/5191b8b733d6bbfd169476c53b6a123b` that I'll refer to as `temp_lib` | ||
|
|
||
| Open it on vscode | ||
| ```bash | ||
| code "/temp_lib" | ||
| ``` | ||
|
|
||
| Do all the changes that you need. | ||
| And then run | ||
| ``` | ||
| diff -Naur node_modules/.pnpm/coinselect@3.1.13/node_modules/coinselect/ /temp_lib | ||
| ``` | ||
|
|
||
| And copy the changes to `patches/coinselect@3.1.13.patch`, just taking the lines with `+/-` preceeded by the ones with `@@`. | ||
|
|
||
| You can now your patch with | ||
| ```bash | ||
| pnpm install --force | ||
| ``` | ||
|
|
||
| If all is good, `patches/coinselect@3.1.13.patch` can be commited as any other file. | ||
|
|
||
| # Why use `diff` manually and not use `pmpm patch-commit temp_lib` ? | ||
|
|
||
| For some reason, it seems pnpm 8 doesn't handle well newly created files (and not just modified ones). This should be better in [pnpm 9](https://github.com/pnpm/pnpm/issues/5686#issuecomment-2272406668) | ||
|
|
||
|
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have some context about the need for this patch? A link or anything.
Not mandatory just in case, could be useful for future reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put those links as context in the description of the PR:
But your comment makes me think that I should put that context closer to the codebase itself. A recommendation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to add the following documentation right next to the patch.