Skip to content

Commit

Permalink
Rename p2sh to p2sh-segwit in js wallet
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewjablack committed Sep 18, 2019
1 parent 3402459 commit 1628bd7
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const NONCHANGE_OR_CHANGE_ADDRESS = 2

const ADDRESS_TYPE_TO_LEDGER_PREFIX = {
'legacy': 44,
'p2sh': 49,
'p2sh-segwit': 49,
'bech32': 84
}

Expand Down Expand Up @@ -93,15 +93,15 @@ export default class BitcoinJsWalletProvider extends Provider {
const wallet = await this.getWalletAddress(inputs[i].address)
const keyPair = await this.keyPair(wallet.derivationPath)
const paymentVariant = this.getPaymentVariantFromPublicKey(keyPair.publicKey)
const needsWitness = this._addressType === 'bech32' || this._addressType === 'p2sh'
const needsWitness = this._addressType === 'bech32' || this._addressType === 'p2sh-segwit'

const signParams = { prevOutScriptType, vin: i, keyPair }

if (needsWitness) {
signParams.witnessValue = inputs[i].value
}

if (this._addressType === 'p2sh') {
if (this._addressType === 'p2sh-segwit') {
signParams.redeemScript = paymentVariant.redeem.output
}

Expand Down Expand Up @@ -198,7 +198,7 @@ export default class BitcoinJsWalletProvider extends Provider {

getScriptType () {
if (this._addressType === 'legacy') return 'p2pkh'
else if (this._addressType === 'p2sh') return 'p2sh-p2wpkh'
else if (this._addressType === 'p2sh-segwit') return 'p2sh-p2wpkh'
else if (this._addressType === 'bech32') return 'p2wpkh'
}

Expand All @@ -209,7 +209,7 @@ export default class BitcoinJsWalletProvider extends Provider {
getPaymentVariantFromPublicKey (publicKey) {
if (this._addressType === 'legacy') {
return bitcoin.payments.p2pkh({ pubkey: publicKey, network: this._network })
} else if (this._addressType === 'p2sh') {
} else if (this._addressType === 'p2sh-segwit') {
return bitcoin.payments.p2sh({
redeem: bitcoin.payments.p2wpkh({ pubkey: publicKey, network: this._network }),
network: this._network })
Expand Down

0 comments on commit 1628bd7

Please sign in to comment.