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

Add new bitcoin@0.17.0 RPC methods to sign raw transactions #80

Merged
merged 1 commit into from
Jun 27, 2019

Conversation

lautarodragan
Copy link
Contributor

Part of #77

Not sure this is right. I just copy-pasted the current signRawTransaction, changing the version and name, and updated the version for the deprecated signRawTransaction.

Tested the "happy path" case — didn't test that the version filters are working, only that I could correctly call this method. That much works well.

src/methods.js Show resolved Hide resolved
src/methods.js Outdated Show resolved Hide resolved
src/methods.js Outdated Show resolved Hide resolved
@lautarodragan
Copy link
Contributor Author

lautarodragan commented Dec 3, 2018

Thank you for your review @pedrobranco!

I went ahead and made the requested changes on signRawTransactionWithWallet.

I also added signRawTransactionWithKey as requested, but I'm not sure whether the obfuscate field is right. (Basically copied what is in place for the deprecated signRawTransaction).

The docs for signRawTransactionWithKey state:

Sign inputs for raw transaction (serialized, hex-encoded).
The second argument is an array of base58-encoded private
keys
that will be the only keys used to sign the transaction.
The third optional argument (may be null) is an array of previous transaction outputs that
this transaction depends on but may not yet be in the block chain.

src/methods.js Outdated Show resolved Hide resolved
src/methods.js Outdated Show resolved Hide resolved
src/methods.js Outdated Show resolved Hide resolved
@pedrobranco pedrobranco changed the title Add signRawTransactionWithWallet Add new bitcoin@0.17.0 RPC methods to sign raw transactions Dec 6, 2018
Copy link
Collaborator

@pedrobranco pedrobranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Squash all commits, and use a commit message like Add new bitcoin@0.17 RPC methods to sign raw transactions.

@pedrobranco
Copy link
Collaborator

Thank you for your review @pedrobranco!

Anytime.

I also added signRawTransactionWithKey as requested, but I'm not sure whether the obfuscate field is right. (Basically copied what is in place for the deprecated signRawTransaction).

The old one was the third argument, in this new method is the second argument. I've already pushed a comment here.

BTW, there is another PR for adding these methods #84. I think we can merge your PR first (despite this PR being a subset of the #84 ).

And many thanks for the pull request 👍

@lautarodragan
Copy link
Contributor Author

@pedrobranco all done I think! Awaiting your input regarding the upper bound in the version range.

@pedrobranco
Copy link
Collaborator

@pedrobranco all done I think! Awaiting your input regarding the upper bound in the version range.

Done.

@lautarodragan
Copy link
Contributor Author

@pedrobranco added the multi wallet feature and removed the version cap. I need to squash again, but other than that, is it looking good?

@pedrobranco
Copy link
Collaborator

@pedrobranco added the multi wallet feature and removed the version cap. I need to squash again, but other than that, is it looking good?

Just add a test for the new multi-wallet method just to be sure that it works fine. To help I've bumped the docker image for the multi-wallet daemon to 0.17.

@pedrobranco
Copy link
Collaborator

@lautarodragan Any news on the missing test? We would like to add this to the new release.

@lautarodragan
Copy link
Contributor Author

@pedrobranco sorry for the delay! just pushed a commit with mutli wallet tests.

@jeamick
Copy link

jeamick commented Apr 1, 2019

Hey @pedrobranco & @lautarodragan,

Any news for this PR ? do we just need to change the commit message ?
Thanks

Kind regards
JM

@pedrobranco @lautarodragan

@lautarodragan
Copy link
Contributor Author

@jeamick @pedrobranco I'll squash the commits but I'd rather wait for feedback first.

I'd like to suggest enabling squash-merging for this repository. It allows a clean master without losing details / history in PRs, and simplifies communication between maintainers and contributors.

@jeamick
Copy link

jeamick commented Apr 4, 2019

I did the change and compiled it into my repository and it works for signRawTransactionWithKey.
here is the link : https://github.com/jeamick/bitcoin-core

@jeamick
Copy link

jeamick commented May 23, 2019

Any update on this PR ? @lautarodragan @pedrobranco

@lautarodragan
Copy link
Contributor Author

lautarodragan commented May 30, 2019

@jeamick I think we can consider this repo pretty much abandoned. I decided to fork it and publish here.

Haven't had a chance to try it yet, if you do please let me know.

I'll be making several changes to the project soon. I intend to keep it compatible with new bitcoin-core releases and add TypeScript type definitions (which I already have for some calls in a different project), as well as fixing some limitations we faced at Po.et.

@ruimarinho
Copy link
Owner

This repo is definitely not abandoned @lautarodragan, but we have been focused on other projects at the moment. This library remains tried and tested. Looking forward to bring back my attention to it.

Which limitations are you trying to solve? Are those public?

@lautarodragan
Copy link
Contributor Author

@ruimarinho that's great news! I think the biggest issue is how we're lagging behind Bitcoin Core releases.

Adding TypeScript definitions and making it compatible with modern ES6 modules would be nice too (although you are setting exports.default = Client so maybe it was an issue on my side).

Another issue I found, albeit minor, was trying to use the methods "outside" the object. I don't know how to explain this properly, but for example doing const { createRawTransaction } = bitcoinCore; createRawTransation(...) failed, if my memory serves me right. Had the same issue trying to pass the functions to Ramda's pipe. I think .bind(bitcoinCore) solved it, but it'd be nice not to need that binding, but it's not very idiomatic.

@jeamick
Copy link

jeamick commented May 30, 2019

@jeamick I think we can consider this repo pretty much abandoned. I decided to fork it and publish here.

Haven't had a chance to try it yet, if you do please let me know.

I'll be making several changes to the project soon. I intend to keep it compatible with new bitcoin-core releases and add TypeScript type definitions (which I already have for some calls in a different project), as well as fixing some limitations we faced at Po.et.

I already did the changes on my repo and it is working : https://github.com/jeamick/bitcoin-core

@lautarodragan
Copy link
Contributor Author

Awesome! Thanks @jeamick. Please let me know if you give the published version a try.

@jeamick
Copy link

jeamick commented May 30, 2019

Awesome! Thanks @jeamick. Please let me know if you give the published version a try.

Which published version ?

I am actually using it for a personal project involving RPC request to bitcoin-core node and everything is working as expected

@lautarodragan
Copy link
Contributor Author

Awesome! Thanks @jeamick. Please let me know if you give the published version a try.

Which published version ?

I am actually using it for a personal project involving RPC request to bitcoin-core node and everything is working as expected

This one: https://www.npmjs.com/package/bitcoins/v/1.0.1

Copy link
Collaborator

@pedrobranco pedrobranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix the minor nits and it's good to merge. Sorry about the delay 😞

@@ -182,6 +168,28 @@ describe('Multi Wallet', () => {
});
});
});

describe('signRawTransactionWithWallet()', () => {
const getFundedTransaction = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistency, please remove this function and define inside each test.

it('should sign a funded raw transaction and return the hex', async () => {
const fundedTransaction = await getFundedTransaction();
const signedTransaction = await client.signRawTransactionWithWallet(fundedTransaction.hex);
signedTransaction.should.have.keys('hex');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline here missing (between await calls and asserts).

it('should support named parameters', async () => {
const fundedTransaction = await getFundedTransaction();
const signedTransaction = await client.signRawTransactionWithWallet({ hexstring: fundedTransaction.hex });
signedTransaction.should.have.keys('hex');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Newline here missing (between await calls and asserts).

@pedrobranco
Copy link
Collaborator

pedrobranco commented Jun 27, 2019

I will submit the fix for the tests and merge this. Also, I've squashed all commits.

Copy link
Collaborator

@pedrobranco pedrobranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants