Coder Social home page Coder Social logo

marinx / monerorpc Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 4.0 76 KB

Full Monero RPC client(Wallet AND Daemon) written in go

License: MIT License

Go 100.00%
monero-api monero monero-wallet-rpc monero-daemon monero-integrations monero-library hacktoberfest

monerorpc's Introduction

Hi 👋 My name is Marin

Software Developer

I work primarily in Go (since 2013), but also have experience in PHP, Flutter, VueJS. I love cloud computing, so I work mostly in cloud environments like Google Cloud and AWS. My home lab consists of self-hosted things like git, CI, personal projects via dokku and other cool stuff. Feel free to ask me about it :)

  • 🌍  I'm based in Croatia
  • 🖥️  See my portfolio at my website
  • ✉️  You can contact me at [email protected]
  • 🧠  I'm learning data structures & algorithms
  • ⚡  One man’s crappy software is another man’s full time job.

Skills

Go PHP Vue TailwindCSS MySQL PostgreSQL Firebase Lavarel Flutter

Socials

Badges

My GitHub Stats

MarinX's GitHub stats

Support Me

monerorpc's People

Contributors

aemet93 avatar dimalinux avatar marinx avatar t-900-a avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

monerorpc's Issues

IncomingTransfer doesn't return subaddr index

Describe the bug
When calling

client.Wallet.IncomingTransfers(&incomingTransfersReq)

the error is returned

json: cannot unmarshal object into Go struct field IncomingTransfer.transfers.subaddr_index of type uint64

To Reproduce
Steps to reproduce the behavior:
https://github.com/t-900-a/fider-monero-bot/blob/b85886d9e1bc26e95f10f35977d505bb64553e73/process-monero/main.go#L82

Expected behavior
A clear and concise description of what you expected to happen.
subaddresses should be parsed correctly

Go Version
Please type your golang version
1.16.5

Monerod Version
Please type your monerod version
17.2.0

GetBalanceResponse is missing fields

Your definition:

type GetBalanceResponse struct {
// The total balance of the current monero-wallet-rpc in session.
Balance uint64 `json:"balance"`
// Unlocked funds are those funds that are sufficiently deep enough in the Monero blockchain to be considered safe to spend.
UnlockedBalance uint64 `json:"unlocked_balance"`
// True if importing multisig data is needed for returning a correct balance.
MultisigImportNeeded bool `json:"multisig_import_needed"`
// Array of subaddress information; Balance information for each subaddress in an account.
PerSubaddress []PerSubaddress `json:"per_subaddress"`
}

The 2 missing fields are:

      uint64_t   blocks_to_unlock;
      uint64_t   time_to_unlock;

Reference:
https://github.com/monero-project/monero/blob/v0.18.1.0/src/wallet/wallet_rpc_server_commands_defs.h#L108-L109

Sample JSON capture returned by get_balance:

{
    "balance": 17981101058456048,
    "blocks_to_unlock": 59,
    "multisig_import_needed": false,
    "per_subaddress": [{
      "account_index": 0,
      "address": "4Ae8FJHMJsnfsghVcg1u3SWqcLyUKCzNVMq8JLZCzgpSKCu6X2mEWZJXAqQpyJsQ11KVXgJDJ24LaBWCjYK8jQXU4NUpiJn",
      "address_index": 0,
      "balance": 17981101058456048,
      "blocks_to_unlock": 59,
      "label": "Primary account",
      "num_unspent_outputs": 512,
      "time_to_unlock": 0,
      "unlocked_balance": 15909955156562018
    }],
    "time_to_unlock": 0,
    "unlocked_balance": 15909955156562018
  }

I opened an issue with the wallet RPC documentation too:
monero-project/monero-site#2022

tagged release?

This looks like a nice library! Have you considered making a tagged release? Before the first release, it might be nice if you renamed the module to github.com/marinx/monerorpc (lower case to follow best practices).

Is the Status field in response structures meaningful?

I noticed that you kept the "Status" field in the response struct types. Is there any API function where the status can have something other than "OK" when no error value was returned?

I realize that I'm asking a question as an issue, but I'm sure others will have the same question. Thanks!

daemon RPC API is missing generateblocks

generateblocks a niche API that is poorly documented, but the type of people using this library are typically running tests on their own code and need this method.

Example:

Start monerod in test mode:

monerod --detach --regtest --offline --fixed-difficulty=1 --rpc-bind-ip 127.0.0.1 --rpc-bind-port 18081

Request:

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"generateblocks","params":{
"amount_of_blocks":1,
"wallet_address":"42eTJxqsYwsSpFCRUp19vPAXNruqAUqnFMY2XN198643Ukrera958dY4qbRdoaoCVffhbC7ro4nzVBMw1E8ip7LAKG3SrsU"}' -H 'Content-Type: application/json'

Response:

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "blocks": ["49b712db7760e3728586f8434ee8bc8d7b3d410dac6bb6e98bf5845c83b917e4"],
    "height": 9783,
    "status": "OK",
    "untrusted": false
  }
}

C++ reference:
https://github.com/monero-project/monero/blob/v0.18.1.0/src/rpc/core_rpc_server_commands_defs.h#L1076-L1107

The prev_block and starting_nonce are not important. I've never seen them documented anywhere, nor have I seen code that passed non-default values to those fields. Here's another point of reference:
https://github.com/cirocosta/go-monero/blob/v0.0.5/pkg/rpc/daemon/jsonrpc.go#L153-L159

GetBlockCountResponse type missing field named Untrusted

The GetBlockCountResponse type is missing a field named Untrusted:
https://github.com/MarinX/monerorpc/blob/v1.0.4/daemon/models.go#L4-L7
https://www.getmonero.org/resources/developer-guides/daemon-rpc.html#get_block_count

$ curl -w "\n" http://127.0.0.1:18089/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_block_count"}' -H 'Content-Type: application/json'
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "count": 2745087,
    "status": "OK",
    "untrusted": false
  }
}

missing field named transfers in GetTransferByTxidResponse

There's a missing array field named transfers in GetTransferByTxidResponse:
https://github.com/MarinX/monerorpc/blob/v1.0.2/wallet/models.go#L903-L907

Here is the documentation link:
https://web.getmonero.org/resources/developer-guides/wallet-rpc.html#get_transfer_by_txid

I don't personally need this field, so no urgency to get it fixed. If you are only sending to a single address with the transfer method, the array is useless, as its single element will be identical to the transfer field. That said, I just confirmed with monero release v0.18.1.2, that passing multiple addresses to the transfer method will yield multiple results in the transfers field of the get_transfer_by_txid response, so the field might be useful to someone.

Daemon GetInfo API can't deserialize responses

The GetInfoResponse struct has a mistyped BusySyncing field. It should be bool, but it's typed string.
https://github.com/MarinX/monerorpc/blob/master/daemon/models.go#L200-L201

Here's test code snippet:

endpoint := fmt.Sprintf("http://%s:%d/json_rpc", monerodHost, monerodPort)
daemonCli := monerorpc.New(endpoint, nil).Daemon
info, err := daemonCli.GetInfo()

The last line above returns an error with the message:

json: cannot unmarshal bool into Go struct field GetInfoResponse.busy_syncing of type string

I'm using monerod release v0.18.1.1 with go1.18.5.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.