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

DLC flow updated to use blockstream API, added regtest #120

Draft
wants to merge 19 commits into
base: develop
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed nested segwit addresses to native segwit ones for demo purposes
  • Loading branch information
Polybius93 committed Mar 22, 2023
commit 81074eb72fcd08d2f45a71188aca374b27a08436
19 changes: 14 additions & 5 deletions wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,22 @@ export async function walletFromSeedPhrase({
const btcChild = master.derivePath(getBitcoinDerivationPath({ index, network }));

const keyPair = ECPair.fromPrivateKey(btcChild.privateKey!);
const segwitBtcAddress = payments.p2sh({
redeem: payments.p2wpkh({
pubkey: keyPair.publicKey,
network: network === 'Mainnet' ? networks.bitcoin : networks.testnet,
}),

// Current nested segwit address they support
// const segwitBtcAddress = payments.p2wpkh({
// redeem: payments.p2sh({
// pubkey: keyPair.publicKey,
// network: network === 'Mainnet' ? networks.bitcoin : networks.testnet,
// }),
// pubkey: keyPair.publicKey,
// network: network === 'Mainnet' ? networks.bitcoin : networks.testnet,
// });

const segwitBtcAddress = payments.p2wpkh({
pubkey: keyPair.publicKey,
network: network === 'Mainnet' ? networks.bitcoin : networks.testnet,
});

const btcAddress = segwitBtcAddress.address!;
const btcPublicKey = keyPair.publicKey.toString('hex');
return {
Expand All @@ -106,6 +114,7 @@ export async function walletFromSeedPhrase({
};
}


function getBitcoinDerivationPath({ index, network }: { index: BigInt; network: NetworkType }) {
return network === 'Mainnet'
? `${BTC_PATH_WITHOUT_INDEX}${index.toString()}`
Expand Down