-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Create and spend from P2WPKH, P2SH-P2WPKH, and P2WSH #2418
Conversation
bceb18a
to
b7e01ab
Compare
b7e01ab
to
63ad16b
Compare
Thank you so much for summiting this. Code and tests (wow!) looks great We definitely want to support it. Please give us a little time to review it in detail, giving this is a big change, but initial overview looks great. Great work! |
@matiu Any more feedback on this PR? |
@matiu Happy new year! Will 2020 be the year of native segwit in Bitcore? |
Hi Andrew, thanks for your collaboration and patience. We definitely want to add native segwit to bitcore in the coming months. We will review soon, as soon as we finish some other wallet related tasks. |
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.
thanks for this great PR!
I left two small comments that lines that need to be removed.
packages/bitcore-lib/lib/transaction/input/multisigscripthash.js
Outdated
Show resolved
Hide resolved
packages/bitcore-lib/lib/transaction/input/multisigscripthash.js
Outdated
Show resolved
Hide resolved
|
||
it('should output this known mainnet wrapped witness address correctly', function() { | ||
var pk = new PublicKey('03c87bd0e162f26969da8509cafcb7b8c8d202af30b928c582e263dd13ee9a9781'); | ||
var address = pk.toAddress('livenet', Address.PayToScriptHash); |
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.
JFYI:
Older copay version used P2SH addresses even for 1-1 wallets.
See: https://github.com/bitpay/bitcore/blob/master/packages/bitcore-wallet-service/src/lib/model/address.ts#L100
We should not confuse this 2 schema, with the same inputs:
- One Pub key to address, using p2sh &
Address.createMultisig
, 1-of-1. - One pub key to address, using p2sh & wrapped witness.
input.countMissingSignatures().should.equal(0); | ||
input.isFullySigned().should.equal(true); | ||
}); | ||
it('returns a list of public keys with missing signatures', function() { |
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.
nice!
Create and spend from P2WPKH, P2SH-P2WPKH, and P2WSH
This PR adds full support for generating and spending from P2WPKH, P2SH-wrapped-P2WPKH, and P2WSH multisig addresses.
Note, I removed the
nestedWitness
parameter forMultiSigScriptHashInput
since it can be inferred by what the publickeys and threshold hash to. This makes it easier to create and spend from these addresses since the method of generating doesn't need to be stored.