Skip to content

RPC add method listsinceblock,getunusedaddress and change getnewaddress#4

Merged
dangershony merged 12 commits into
masterfrom
unknown repository
Oct 17, 2019
Merged

RPC add method listsinceblock,getunusedaddress and change getnewaddress#4
dangershony merged 12 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Oct 15, 2019

Copy link
Copy Markdown
  • Change getnewaddress method so that it will always generate a new address
  • Add listsinceblock method

Kees de Wit added 2 commits October 15, 2019 19:15
Fix block height condition

@dangershony dangershony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Generally looks good perhaps also add the method to the list of RPC methods

[ActionName("getnewaddress")]
[ActionDescription("Returns a new wallet address for receiving payments.")]
public NewAddressModel GetNewAddress(string account, string addressType)
public NewAddressModel GetNewAddress(string account = "", string addressType = "")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we have an optional parameter to indicate the flow generating new or asking for a current unused?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Or perhaps this should be a setting value that defaults to false?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We should keep this compatible with how other Bitcoin implementations work. Adding additional parameters and/or configuration settings would require the integrating party to do additional work. That will be a hurdle for exchanges to adopt the coins because every new exchange has to write custom code or has to have custom knowledge to support our coins.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The problem this is an HD wallet and just generating a new address comes with consequences (one needs to maintain a standard gap for recovery to work)

That's why I propose a settings flag to invert this, alternatively we can pass a mandatory field in recovery that takes a gap then an exchange that does recovery can juts put a very big number there

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Settings flag already in place: "walletaddressbuffer" defaults to 20


int blockHeight = transactionData.BlockHeight ?? 0;

if (block != null && blockHeight < this.ChainIndexer.GetHeader(block?.GetHash()).Height)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is waistfull, you can instead vat the method above GetBlock also fetch the header

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in commit 2e8fdc9

}
}

model.LastBlock = this.ConsensusManager.Tip.HashBlock;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's better practice to use the tip of ChainIndexer

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Resolved in commit 4753e12

[ActionName("listsinceblock")]
[ActionDescription("Get all transactions in blocks since block 'blockhash', or all transactions if omitted.")]
public async Task<ListSinceBlockModel> ListSinceBlockAsync(string blockHash, int targetConfirmations = 1)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Did you base the logic on bitcoin core by any chance?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This should be the same logic that is used in bitcoin core

HdAccount walletAccount = wallet.GetAccount(accountReference.AccountName);
HdAddress hdAddress = walletAccount.CreateAddresses(this.Network, 1).Single();

string base58Address = hdAddress.Address;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ah hang on I think this is missing some functionality here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Brilliant looks much better actually

@dangershony dangershony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Discussion on going in discord

int index = this.context.ActionContext.ActionDescriptor.Parameters.IndexOf(parameter);
var parameters = (JArray)req["params"];

if (parameters == null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

ok excellent I think a fix was made in stratis repo a well

@dangershony dangershony left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me

@dangershony dangershony changed the title RPC change/add methods RPC add method listsinceblock,getunusedaddress and change getnewaddress Oct 17, 2019
@dangershony
dangershony merged commit 6ef036a into block-core:master Oct 17, 2019
dangershony pushed a commit that referenced this pull request Feb 2, 2022
 Add Transaction Details Dialog
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.

1 participant