Question about the java API.
Are there any plans to extract the functionality of the handlers in in nxt.http into java interfaces.
My use case is to create a payment transaction but i dont want to go through the HTTP layer. Currently to send money from the java api you would have to duplicate all the steps taken in for instance nxt.http.SendMoney.
The Java API is still a work in progress, in fact I am just in the middle of another refactoring for 0.8.0. I am switching to embedded jetty, so Nxt will no longer be a servlet. I will also improve the API while at it.
For the SendMoney example, what kind of an API would you find useful? Right now the steps you would need to duplicate are not that many, basically you need to do:
Transaction transaction = Transaction.newTransaction(Convert.getEpochTime(), deadline, publicKey,
recipient, amount, fee, referencedTransaction);
transaction.sign(secretPhrase);
Blockchain.broadcast(transaction);
The rest is validating the user input and returning error messages, which is application specific. If you submit an invalid transaction, it will not be accepted, and a lot of validation is done immediately when the Transaction object is constructed (such as for non-negative amount and fee, deadline, timestamp). Other validations, such as the account having enough funds are only done when the Transaction is about to be included in a block (because the account balance may have changed in the meantime).
Hi! You are right the steps to send money are very limited indeed, i already went ahead and did things that way. Looking at it now i no longer think there should be a higher level api apart from what is provided.
While i have your attention might i point you to the following..
Currently there is no way for java clients to get notified of progress during startup (nxt.Nxt.init())
Ideally there would be a listener you could register or some sort of progress monitor. In eclipse you have the IProgressMonitor interface, such an interface would be perfect, i included a simplified example.
public interface IProgressMonitor {
public void beginTask(String name, int totalWork);
public void done();
public void worked(int work);
}
The monitor would be provided by the user and is passed to the various startup methods. When reading the blockchain (for instance) you would call monitor.beginTask("Read blockchain", totalNumberOfBlocks) and then on each (or each 5th, 10th etc.) block read you call monitor.worked(numberOfBlocksRead). At the end you would call monitor.done().
> I am switching to embedded jetty
That's how we have done it from the start. But what is wrong with the servlet, should you not stay far from jetty and focus solely on nxt core?
Nice to meet you btw.. You did a nice job on the refactorings.