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

Import/Export #61

Merged
merged 12 commits into from
Sep 27, 2019
Merged

Import/Export #61

merged 12 commits into from
Sep 27, 2019

Conversation

nodech
Copy link
Member

@nodech nodech commented Jul 25, 2019

  • Exports Wallet with cosigners and account.
  • This format can be reused in bcoin as well (maybe minor improvements) and should be compatible
  • ❌ Currently does not export/import imported addresses.
  • ❌ received, change and nested depth is not recovered (for now)

@nodech nodech added the WIP work in progress label Jul 25, 2019
@nodech nodech force-pushed the import-export branch 3 times, most recently from 05e618b to 93788f7 Compare August 2, 2019 19:16
@nodech nodech removed the WIP work in progress label Aug 4, 2019
@nodech nodech mentioned this pull request Aug 4, 2019
3 tasks
* Wraps Cosigner primitive.
*/

class CosignerDetails extends Struct {
Copy link
Member

Choose a reason for hiding this comment

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

Why is there a CosignerDetails object when it doesn't add anything additional to the Cosigner?

Copy link
Member Author

Choose a reason for hiding this comment

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

To make better wrapper for serializers. Cosigner unlike Wallet and Account is already serializable so I just wrapped it so it does not expose functionality that wont work (mostly client side)

*/

class CosignerDetails extends Struct {
constructor() {
Copy link
Member

Choose a reason for hiding this comment

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

Should the constructor be able to take the Cosigner as well? Its not very useful to use new CosignerDetails() unless you wanted a nil cosigner object

Copy link
Member Author

Choose a reason for hiding this comment

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

All these serializers give you default object. So I don't think having many ways to pass cosigner will improve much. (Especially these always clone the data passed.)

lib/export.js Outdated
master: this.master.toRaw().toString('hex'),
joinPubKey: this.joinPubKey.toString('hex'),
timestamp: this.timestamp,

Copy link
Member

Choose a reason for hiding this comment

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

Nit: empty space

lib/export.js Outdated
bw.writeU40(this.timestamp);
bw.writeBytes(this.joinPubKey);

bw.writeU8(this.accounts.length);
Copy link
Member

Choose a reason for hiding this comment

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

I don't see any checks to make sure this won't overflow

Copy link
Member Author

Choose a reason for hiding this comment

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

Multisig only has one account, but true this needs change to be useful for bcoin.

/**
* Export wallet. (without lock)
* @param {Number} wid
* @returns [Wallet, Account[], Cosigner[]]
Copy link
Member

Choose a reason for hiding this comment

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

This docstring looks out of date

assert(account.type === Account.types.MULTISIG);
assert(account.name === 'default');
assert(account.initialized === true);
assert(account.accountIndex === 0);
Copy link
Member

Choose a reason for hiding this comment

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

Why does the accountIndex need to be 0 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Multisig wallets only have one account in them, so it should never be more than 0.

Copy link
Member

Choose a reason for hiding this comment

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

That would be good to add as a comment

@nodech nodech merged commit af60704 into bcoin-org:master Sep 27, 2019
nodech added a commit that referenced this pull request Sep 27, 2019
@nodech nodech deleted the import-export branch April 2, 2020 18:11
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.

2 participants