Jump to content

Tutorial: Use Interledger with Moneyd GUI


Recommended Posts

https://medium.com/interledger-blog/use-interledger-with-moneyd-gui-21dee0dc8ba0

"Moneyd aims to make it as easy as possible to join the Interledger network. Now, Interledger is even easier to use thanks to the Moneyd GUI."

Additional Tutorials are at Interledger Blog:  https://medium.com/interledger-blog

Edited by NightJanitor
Link to comment
Share on other sites

err, I must have made some noob mistake with this.

created an account rNe1Eg8h9JbivEh5BtXBxmDjwb59k2wrva and credited it with 50 XRP

then played around with the SPSP examples on the javascript console. 

It seemed to have failed, but then I looked up my account on bithomp and saw it created a payment channel.

Somehow it locked 10 XRP into the channel.

Even though the amounts in the examples are very small, when I then ran moneyd cleanup it said :

index  destination                         amount (drops)  balance (drops)  closing
0      rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN  10000000        10000
 

When I closed it I didn't get the 10 XRP back. Furthermore there is no sign of the balance in rK6g2UYc4GpQH8DYdPG7wywyQbxkJpQTTN  increasing by 10.

Where did the XRP actually go?

 

PaymentChannelCreate - 7FD7D5F5E5A170E94B0A229CDE61170CCE2B3476BE84ECA265FCB13231F8E680

PaymentChannelClaim - 

my side - B80D809C2D4654964F728E288CFB6B9B605ED3ECC5BE32DEE27AAE018E035733

other side - 4764E0D60451A2BC9D1EDE27039C3C9F4B2BDE67644BD1393B59B61578D54809

 

TL;DR 10 XRP committed into a payment channel and then when closed both sides are credited a near-0 value from it.

Edited by corak
Link to comment
Share on other sites

It looks like PaymentChannelClaim does not close the channel unless the "tfClose" flag is sent with the transaction. The transactions seem to claim any debt between the 2 wallets, since the wallets have no mutual debt across the payment channel, they claim 0XRP, pay a small fee and then keep the channel open. Including the flag with the transaction, mightshould close it and return the 10xrp.

https://ripple.com/build/transactions/#paymentchannelclaim

Edited by EasterBunny
Link to comment
Share on other sites

After reading through the documentation a bit more, I think I have a better idea of how the payment channels work. Let me illustrate:

Say Alice wants to send Bob 10 XRP. She could of course sent it as a payment, or she could open up a payment channel and put 10XRP on Bob's end. Alice's balance reduces by 10, and Bob's balance stays the same because he has not yet claimed the channel. He could then send a PaymentChannelClaim with the "tfClose" flag and it will close the channel and increase Bob's account by 10XRP. 

Let's say Bob keeps his 10XRP payment channel open, and he later decides to send Alice 1XRP. He has 3 options.

  1. He sends Alice a regular Payment Transaction for 1XRP
  2. He sends Alice a PaymentChannelFund transaction with an 'amount' of 1XRP
    1. The payment channel now has 11XRP, with 10XRP allocated to Bob and 1XRP for Alice
  3. He sends Alice a PaymentChannelClaim transaction with an 'amount' of 1XRP
    1. If the 'tfClose' flag is enabled, the PaymentChannel will close, Bob will be credited 9XRP and Alice with 1XRP.
    2. If the 'tfClose' flag is not enabled, the PaymentChannel will stay open and Bob and Alice's Wallet balances won't change, But the payment channel will have 10 XRP in it, 9XRP allocated to Bob, and 1XRP to Alice

I hope the above explanation is correct.

Link to comment
Share on other sites

I am far removed from writing actual code (but I do still read it) and visualize paychan as a sort of a "real-time revolving escrow".  If one thinks of it in that way, a "close" signal is a must.

Please keep experimenting and let us know how it goes.  (Also, please see my note in your other thread:  I thiink you can get 10k XRP for "risk-free" experimentation on the ILP TestNet.)

Link to comment
Share on other sites

1 minute ago, NightJanitor said:

I am far removed from writing actual code (but I do still read it) and visualize paychan as a sort of a "real-time revolving escrow".  If one thinks of it in that way, a "close" signal is a must.

Please keep experimenting and let us know how it goes.  (Also, please see my note in your other thread:  I thiink you can get 10k XRP for "risk-free" experimentation on the ILP TestNet.)

The TX to close the channel could've been malformed, but I didn't issue it by hand - I used the "moneyd cleanup" command. If a flag is needed to close the channel I'd expect it to be given.  

I'll try to submit a PaymentChannelClaim myself and see if it works

Link to comment
Share on other sites

I think the issue is that there was no 'Amount' field in the transaction.

 Object
hash:  "B80D809C2D4654964F728E288CFB6B9B605ED3ECC5BE32DEE27AAE018E035733"
ledger_index: 38069056
date:  "2018-04-19T10:29:30+00:00"
 tx: Object
TransactionType:  "PaymentChannelClaim"
Flags: 2147614720
Sequence: 2
LastLedgerSequence: 38069057
Channel:  "95CEF40E0347B9EBC3070A289FB05F4A06DB4DC6DA830D0B41D98EB0DC15714F"
Fee:  "12"
SigningPubKey:  "024410E2AB726E61DE08F6C4199D38F6FC30F4D774A4D2D7CFC9798332E412346B"
TxnSignature: "3045022100C0520019CCE82257D5A25241B36C0D7D00380067DE092D9F632175DA81FBDF4F02203B1596E7EC6E7FEE7ADC062B04721F593B3FDAEE0BEFB9F81AA2F75284CD5AF0"
Account:  "rNe1Eg8h9JbivEh5BtXBxmDjwb59k2wrva"
 meta: Object
TransactionIndex: 15
 AffectedNodes: Array [2]
 0: Object
 1: Object
TransactionResult:  "tesSUCCESS"

You sent a PaymentChannelClaim with an amount of zero(by default because it was omitted). The amount(zero) was claimed, but they payment channel was left open because the 'tfClose' flag was not received. If the flag would have been received, then the payment channel would have closed and the balance on the payment channel would have been paid out, reclaiming the 10XRP.

Link to comment
Share on other sites

1 hour ago, NightJanitor said:

Please keep experimenting and let us know how it goes.  (Also, please see my note in your other thread:  I thiink you can get 10k XRP for "risk-free" experimentation on the ILP TestNet.)

Just FYI:

The ILP testnet "interfaucet" (which hands out free XRP candy to peeps) appears to be down for maint, atm, but I think it lives here:  https://github.com/interledgerjs/interfaucet

(They've had to move that around several times; I think at one point it was maybe in http-oer, and, maybe, at another point, was living with amundsen - but it would be nice if they made that more clear and included explicit "free XRP" instructions in the tutorials - especially as more attention/interest builds in developing businesses through (and with) both Interledger ILP and Web Monetization - and other goodies.)

Interledger lives here:  https://github.com/interledger

InterledgerJS lives here:  https://github.com/interledgerjs

Both can be searched;  a lot of good stuff to read in there.

Edited by NightJanitor
Link to comment
Share on other sites

I tried to restart moneyd and somehow it claimed my previous PayChan and then immediately created another one for 10 XRP again (fml).

An hour later, I tried to PaymentChannelClaim with Balance: 0 (because the balance was really 0 - nothing was paid). That failed - balance can't be zero, it said. I changed balance to 10000000, and now the receiving address has my 10 XRP ... brilliant.

Well, play stupid games win stupid prizes, as they say

Link to comment
Share on other sites

7 hours ago, corak said:

To be honest the request to claim/close a PayChan with balance 0 seems perfectly legitimate, and having it fail is a bug as far as I can tell

raise issue on ripple's github. They are way faster to respond there than here. 

Link to comment
Share on other sites

They fixed the bug with moneyd cleanup; the issue with "balance: 0" causing the TX to fail is intended

 

Now with the PayChan gone, when I try to run moneyd, I get this error:

2018-04-21T19:14:39.932Z connector:app error [RippledError(entryNotFound)]

moneyd-gui can't communicate with it even if I do run it with --admin-api-port 7769

I wonder what's going on. Maybe I'll start rummaging blindly inside the moneyd codebase for a bit :)

Link to comment
Share on other sites

2 hours ago, corak said:

They fixed the bug with moneyd cleanup; the issue with "balance: 0" causing the TX to fail is intended

Yeah, I kinda suspected that;  it's been a minute since I looked into the code, but I think there was an implicit/hard-coded (maybe now definable?) condition that would keep the channel open for exactly 3600 seconds (1 hour) in order to give Bob the chance to submit his "best claim" against the escrowed funds in the channel.  If Alice could close the channel, instantly, and at will, which, coincidentally, would keep Bob from submitting his "claim" against the escrowed funds in the channel, then that opens a rather nasty door to abuse.  Thusly, that time condition within the initial channel opening and, if I'm thinking about this properly, also the inability for the opening party (Alice) to manually/"shoplift-ily" do a tx to "reclaim" (close/collapse/disavow) escrow, effectively enabling a sort of "beat-the-check" / "beat-the-clock" game, where one could just go and (to use a CC metaphor) "pre-auth" their Louboutin's - keep 'em - and "cancel their card" - by beating Bob's shoe-store to to his claim submission.  Thinking about it, I do believe I saw that they've made the time field definable, now.  (Different use cases need different time windows...)

I highly suggest "rummaging blindly" inside not only the moneyd codebase but also in many others.  There are some fascinating issues - and creative/enlightening talks on solving 'em.  :)

I've found the paystream code (and the issue discussions) to be especially good;  some approach it as "let's perfect a single-use solution that scales" and others (Bob Way!) have streaming movies playing in their heads and seem to approach from wanting to build their own streaming platform, solve for that, and then abstract back down to single unit cases.  It's fun watching a bunch of really smart guys attack problems from different angles, with an incredible amount of respect for one another and for the ultimate goal of their mission, and converge on solutions.

Link to comment
Share on other sites

  • 3 weeks later...

Hey guys, I'm pretty new to javascript and want to give the testnet a try. I have downloaded node.js and have installed npm and git into the command prompt globally. I have tried to install Moneyd, however, its being a pain in the butt. 

Here is the error message:

Quote

C:\Users\Matthew>npm install -g moneyd
npm ERR! prepareGitDep 1>
npm ERR! prepareGitDep > husky@0.14.3 install C:\Users\Matthew\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-77225248\node_modules\husky
npm ERR! prepareGitDep > node ./bin/install.js
npm ERR! prepareGitDep
npm ERR! prepareGitDep husky
npm ERR! prepareGitDep setting up Git hooks
npm ERR! prepareGitDep done
npm ERR! prepareGitDep
npm ERR! prepareGitDep
npm ERR! prepareGitDep > leveldown@3.0.0 install C:\Users\Matthew\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-77225248\node_modules\leveldown
npm ERR! prepareGitDep > prebuild-install || node-gyp rebuild
npm ERR! prepareGitDep
npm ERR! prepareGitDep
npm ERR! prepareGitDep C:\Users\Matthew\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-77225248\node_modules\leveldown>if not defined npm_config_node_gyp (node "C:\Users\Matthew\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "C:\Users\Matthew\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
npm ERR! prepareGitDep
npm ERR! prepareGitDep 2> npm WARN install Usage of the `--dev` option is deprecated. Use `--only=dev` instead.
npm ERR! prepareGitDep prebuild-install info begin Prebuild-install version 2.5.0
npm ERR! prepareGitDep prebuild-install info looking for local prebuild @ prebuilds\leveldown-v3.0.0-node-v64-win32-x64.tar.gz
npm ERR! prepareGitDep prebuild-install info looking for cached prebuild @ C:\Users\Matthew\AppData\Roaming\npm-cache\_prebuilds\https-github.com-level-leveldown-releases-download-v3.0.0-leveldown-v3.0.0-node-v64-win32-x64.tar.gz
npm ERR! prepareGitDep prebuild-install http request GET https://github.com/level/leveldown/releases/download/v3.0.0/leveldown-v3.0.0-node-v64-win32-x64.tar.gz
npm ERR! prepareGitDep prebuild-install http 404 https://github.com/level/leveldown/releases/download/v3.0.0/leveldown-v3.0.0-node-v64-win32-x64.tar.gz
npm ERR! prepareGitDep prebuild-install WARN install No prebuilt binaries found (target=10.0.0 runtime=node arch=x64 platform=win32)
npm ERR! prepareGitDep gyp ERR! configure error
npm ERR! prepareGitDep gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! prepareGitDep gyp ERR! stack     at PythonFinder.failNoPython (C:\Users\Matthew\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
npm ERR! prepareGitDep gyp ERR! stack     at PythonFinder.<anonymous> (C:\Users\Matthew\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
npm ERR! prepareGitDep gyp ERR! stack     at C:\Users\Matthew\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
npm ERR! prepareGitDep gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:149:21)
npm ERR! prepareGitDep gyp ERR! System Windows_NT 10.0.16299
npm ERR! prepareGitDep gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Matthew\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
npm ERR! prepareGitDep gyp ERR! cwd C:\Users\Matthew\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-77225248\node_modules\leveldown
npm ERR! prepareGitDep gyp ERR! node -v v10.0.0
npm ERR! prepareGitDep gyp ERR! node-gyp -v v3.6.2
npm ERR! prepareGitDep gyp ERR! not ok
npm ERR! prepareGitDep npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules\fsevents):
npm ERR! prepareGitDep npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! code ELIFECYCLE
npm ERR! prepareGitDep npm ERR! errno 1
npm ERR! prepareGitDep npm ERR! leveldown@3.0.0 install: `prebuild-install || node-gyp rebuild`
npm ERR! prepareGitDep npm ERR! Exit status 1
npm ERR! prepareGitDep npm ERR!
npm ERR! prepareGitDep npm ERR! Failed at the leveldown@3.0.0 install script.
npm ERR! prepareGitDep npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! prepareGitDep
npm ERR! prepareGitDep npm ERR! A complete log of this run can be found in:
npm ERR! prepareGitDep npm ERR!     C:\Users\Matthew\AppData\Roaming\npm-cache\_logs\2018-05-09T01_54_21_244Z-debug.log
npm ERR! prepareGitDep
npm ERR! premature close

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Matthew\AppData\Roaming\npm-cache\_logs\2018-05-09T01_54_21_423Z-debug.log

Any help would be appreciated!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...