-
Notifications
You must be signed in to change notification settings - Fork 21
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
DLC flow updated to use blockstream API, added regtest #120
Draft
Polybius93
wants to merge
19
commits into
develop
Choose a base branch
from
feat/dlc-blockstream_support
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+384
−251
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
817d6b4
Added BlockCypher Testnet to network types and extended each BlockCyp…
Polybius93 17e645f
Merge pull request #85 from secretkeylabs/develop
m-aboelenein d95fe84
Merge pull request #87 from secretkeylabs/develop
m-aboelenein 3b0e1e9
Added BlockCypher option
Polybius93 81074eb
Changed nested segwit addresses to native segwit ones for demo purposes
Polybius93 53bf402
Added dlcBtcAddress to use native segwit address
Polybius93 796e38f
Merged develop
Polybius93 5a98070
Merge branch 'develop' into feat/blockcypher-testnet
Polybius93 cb8dab9
Updated package-lock.json
Polybius93 baff9aa
Removed unnecessary console logs
Polybius93 64b8dda
Merged develop updates
Polybius93 68a69de
Merged migrate-blockstream to branch
Polybius93 4d4244e
Added getRawTransaction function to esplora
Polybius93 7572e15
Merged fix into branch
Polybius93 87b4d3b
Added regtest support
Polybius93 2c27015
Merge remote-tracking branch 'origin/develop' into feat/nativesegwita…
m-aboelenein e93b99d
Merge remote-tracking branch 'origin/develop' into feat/nativesegwita…
m-aboelenein 10d0876
refactored native segwit address derivation
m-aboelenein 72f9c82
Merge branch 'feat/nativesegwitaddress_support' into feat/dlc-blockst…
m-aboelenein 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
Binary file not shown.
This file contains 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 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 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 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 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 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 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 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 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 |
---|---|---|
|
@@ -21,12 +21,19 @@ const bitcoinTestnet: BitcoinNetwork = { | |
wif: 0xef, | ||
}; | ||
|
||
const bitcoinRegtest: BitcoinNetwork = { | ||
bech32: 'bcrt', | ||
pubKeyHash: 0x6f, | ||
scriptHash: 0xc4, | ||
wif: 0xef, | ||
Comment on lines
+25
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since these are used twice, consider defining them in a const object |
||
}; | ||
|
||
export const bitcoinNetworks: Record<NetworkType, BitcoinNetwork> = { | ||
Mainnet: bitcoinMainnet, | ||
Testnet: bitcoinTestnet, | ||
Regtest: bitcoinRegtest, | ||
}; | ||
|
||
export const getBtcNetwork = (networkType: NetworkType) => { | ||
return bitcoinNetworks[networkType]; | ||
}; | ||
|
This file contains 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,8 +1,50 @@ | ||
export function ecPairToHexString(secretKey: any) { | ||
var ecPointHex = secretKey.privateKey.toString('hex'); | ||
const ecPointHex = secretKey.privateKey.toString('hex'); | ||
if (secretKey.compressed) { | ||
return ecPointHex + '01'; | ||
} else { | ||
return ecPointHex; | ||
} | ||
} | ||
|
||
interface EncryptMnemonicArgs { | ||
password: string; | ||
seed: string; | ||
passwordHashGenerator: (password: string) => Promise<{ | ||
salt: string; | ||
hash: string; | ||
}>; | ||
mnemonicEncryptionHandler: (seed: string, key: string) => Promise<Buffer>; | ||
} | ||
|
||
interface DecryptMnemonicArgs { | ||
password: string; | ||
encryptedSeed: string; | ||
passwordHashGenerator: (password: string) => Promise<{ | ||
salt: string; | ||
hash: string; | ||
}>; | ||
mnemonicDecryptionHandler: (seed: Buffer | string, key: string) => Promise<string>; | ||
} | ||
|
||
export async function encryptMnemonicWithCallback(cb: EncryptMnemonicArgs) { | ||
const { mnemonicEncryptionHandler, passwordHashGenerator, password, seed } = cb; | ||
try { | ||
const { hash } = await passwordHashGenerator(password); | ||
const encryptedSeedBuffer = await mnemonicEncryptionHandler(seed, hash); | ||
return encryptedSeedBuffer.toString('hex'); | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
} | ||
|
||
export async function decryptMnemonicWithCallback(cb: DecryptMnemonicArgs) { | ||
const { mnemonicDecryptionHandler, passwordHashGenerator, password, encryptedSeed } = cb; | ||
try { | ||
const { hash } = await passwordHashGenerator(password); | ||
const seedPhrase = await mnemonicDecryptionHandler(encryptedSeed, hash); | ||
return seedPhrase; | ||
} catch (err) { | ||
return Promise.reject(err); | ||
} | ||
} |
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.
Here a sequence of ternaries seems a bit too confusing to read and understand. I would recommend just doing a switch, which will be more clear.
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 see you did that in wallet/index.ts too, so it's probably more consistent too.