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

CLI instead of Web-Frontend? #20

Open
michael-holzheu opened this issue Sep 9, 2022 · 17 comments
Open

CLI instead of Web-Frontend? #20

michael-holzheu opened this issue Sep 9, 2022 · 17 comments

Comments

@michael-holzheu
Copy link

I would like to use "Perpera" to save hashes of documents on the peercoin blockchain.

Up to now I only found your Web-Frontend: https://perpera.peercoin.net

This is almost what I was looking for, but I don't want to paste my private key into an unknown browser window.

Is there any other easy way (e.g. a command line interface) to use "Perpera" without having to transfer the private key via an unsecured connection?

@michael-holzheu michael-holzheu changed the title CLI instad of Web-Frontend? CLI instead of Web-Frontend? Sep 9, 2022
@jointhepartypooper
Copy link

i suppose you can run the code on https://github.com/peercoin/perpera-web on localhost?

@michael-holzheu
Copy link
Author

michael-holzheu commented Sep 9, 2022

Ok, I now got it running in a Docker container with an Ubuntu image and "npm install/start" as described in the README, thanks 👍!

@michael-holzheu
Copy link
Author

I assume the private key is not sent to the outside by the script, right?

@michael-holzheu
Copy link
Author

When I enter the private key, which I got by "dumpprivkey ..." from the peercoin-qt console, "perpera-web" shows me "Your wallet has no funds", which is not true.

In the PeerCoin Explorer I see enough coins on the corresponding public key: https://chainz.cryptoid.info/ppc/address.dws?PRoiyRWKx1HtKQsV2CibjcyHA2B8Fo9B91.htm

Any idea?

@michael-holzheu
Copy link
Author

michael-holzheu commented Sep 10, 2022

The error seems to occur in src/services/Perpera.ts#getFee.

@peerchemist
Copy link
Member

I assume the private key is not sent to the outside by the script, right?

It's only used by the spender to sign the transaction.

@michael-holzheu
Copy link
Author

michael-holzheu commented Sep 10, 2022

The failing function is public/perpera.js:update.add():

const utxos = this.spender.allocate(fee - balance);
if (utxos === null)
    throw new Error('Insufficient funds.');

For my sample document and private key the values of "fee" and "balance" are:

  • fee: 1.000
  • balance: -20.000

The callstack up to this point is as follows:

@michael-holzheu
Copy link
Author

michael-holzheu commented Sep 10, 2022

I now tried to switch to the Peercoin "testnet" by the following change:

git diff src/services/Perpera.ts
diff --git a/src/services/Perpera.ts b/src/services/Perpera.ts
index 91d2f61..f78028e 100644
--- a/src/services/Perpera.ts
+++ b/src/services/Perpera.ts
@@ -4,7 +4,7 @@ export default class PerperaService {
 
   constructor(network?: string) {
     this.perpera = window['perpera'];
-    this.network = network || window['perpera'].networks['peercoin'];
+    this.network = network || window['perpera'].networks['peercoin-testnet'];
   }
 
   public getDocument(hash: string) {

With the corresponding private key for my new peercoins, I now get "WIF invalid" respectively "TypeError: Private key network mismatch".

@peerchemist
Copy link
Member

It seems you are trying to use it on mainnet, so just leave it on mainnet.

@peerchemist
Copy link
Member

I believe that fee calculation logic was extremely out of date. This bit of software is unmaintained for about 4 years.

#21

I think this will resolve it.

@michael-holzheu
Copy link
Author

I believe that fee calculation logic was extremely out of date. This bit of software is unmaintained for about 4 years.

#21

I think this will resolve it.

I changed the file public/perpera.js accordingly, but unfortunately it did not fix the problem. The fee is still "1000". I assume that the "balance" is the problem here?

@michael-holzheu
Copy link
Author

It seems you are trying to use it on mainnet, so just leave it on mainnet.

Nevertheless for development it would be nice to be able to switch to "testnet". Could you tell me what is necessary to do that?

@peerchemist
Copy link
Member

Well, sorry I can't do much to help you out. I'm totally not into frontends or JS ecosystem in general. Unfortunately, the person who wrote this frontend is absent for a while.

But really this should not be so difficult to update, patch and deploy fixed version,

@michael-holzheu
Copy link
Author

Is your public Web-Frontend (https://perpera.peercoin.net) working for you, or does it show the same problem?

@peerchemist
Copy link
Member

Yes, same problem.

I've figured out it calls now defunct explorer API. I've removed the support for that API from the source.
Could you build and try again?

@michael-holzheu
Copy link
Author

I've figured out it calls now defunct explorer API. I've removed the support for that API from the source. Could you build and try again?

What do I have to do here exactly? You removed the file "explorer.ts" in the "perpera" git repository. I don't find this file in the "perpera-web" git repository.

@peerchemist
Copy link
Member

Now, this lib must be built and included into the perpera-web.

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

No branches or pull requests

3 participants