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

Hotfix/ridvan non changing wallet #65

Merged
merged 4 commits into from
Jun 10, 2021

Conversation

rozaydin
Copy link

@rozaydin rozaydin commented Jun 10, 2021

This PR prevents static addresses to create new keys and it always defaults to

// If static address do not let creation of new keys   
if (this.staticAddress) {     
   return this.getSpecificKey(0,0);    
}

I have verified the hsw use case and below is my results with this PR

roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$ ./hsw-cli --network regtest --api-key roo --id static-test2 --account default address
{
"name": "default",
"account": 0,
"branch": 0,
"index": 0,
"publicKey": "0242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d60",
"script": "52210242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d602103e0eb897d5caf94aba71a25358530939efbe7e94933fd157fffd59f6ec8efeeb652ae",
"address": "rs1qmh37d7x2nu0en4k0z302cv4mflz5n37jq9zcfz9wyckk8wz5eutscxlwsq"
}
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$ ./hsw-cli --network regtest --api-key roo --id static-test2 --account default address
{
"name": "default",
"account": 0,
"branch": 0,
"index": 0,
"publicKey": "0242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d60",
"script": "52210242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d602103e0eb897d5caf94aba71a25358530939efbe7e94933fd157fffd59f6ec8efeeb652ae",
"address": "rs1qmh37d7x2nu0en4k0z302cv4mflz5n37jq9zcfz9wyckk8wz5eutscxlwsq"
}
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$
roza-mac-pro:bin rozaydin$ ./hsw-cli --network regtest --api-key roo --id static-test2 --account default address
{
"name": "default",
"account": 0,
"branch": 0,
"index": 0,
"publicKey": "0242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d60",
"script": "52210242ad36133b4932aaac9269f18ca6a4db4886308efa168fdbe1d8ebd8ad791d602103e0eb897d5caf94aba71a25358530939efbe7e94933fd157fffd59f6ec8efeeb652ae",
"address": "rs1qmh37d7x2nu0en4k0z302cv4mflz5n37jq9zcfz9wyckk8wz5eutscxlwsq"
}

I have also added a feature test to check this functionaliy on feature tests

Feature: static wallet interaction
  As a static wallet user I need to use same
  receive and change address for all interactions
  I engage

Scenario: Create a static Wallet
  Given I create "static" wallet with staticAddress property set to true
  When I query list of wallets
  Then "static" wallet should be present within list of wallets
  And "default" account on "static" wallet should have staticAddress property set to true

Scenario: Calling create change address should always return same address
  Given I call "static" wallets create change address 100 times using "default" account all addresses should be same

Scenario: Calling create receive address should always return same address
  Given I call "static" wallets create receive address 100 times using "default" account all addresses should be same

Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
Signed-off-by: rozaydin <ridvan@namebase.io>
@rozaydin rozaydin requested a review from turbomaze June 10, 2021 11:00
@@ -378,7 +384,7 @@ class Account extends bio.Struct {
throw new Error(`Bad branch: ${branch}.`);
}

this.save(b);
await this.save(b);

Choose a reason for hiding this comment

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

What is this code change? I don't want to deviate from master unnecessarily

Copy link
Author

Choose a reason for hiding this comment

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

it was not waiting for the result to written out to leveldb, so i thougth it would be a good idea to make it wait write the record and return. but yes it's a deviation. rolling back

Copy link
Author

Choose a reason for hiding this comment

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

rolled back

Signed-off-by: rozaydin <ridvan@namebase.io>
@turbomaze turbomaze merged commit db725c6 into production-namebase Jun 10, 2021
@turbomaze turbomaze deleted the hotfix/ridvan-non-changing-wallet branch June 10, 2021 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants