diff --git a/go.mod b/go.mod index 15c275f..b8bb082 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module github.com/MarinX/monerorpc -go 1.14 +go 1.19 require ( - github.com/gabstv/httpdigest v0.0.0-20200601123255-912d52c2d608 + github.com/gabstv/httpdigest v0.0.0-20230306144402-1057ac3638b3 github.com/gorilla/rpc v1.2.0 - github.com/matryer/is v1.4.0 // indirect ) + +require github.com/matryer/is v1.4.0 diff --git a/go.sum b/go.sum index ec38ca3..d9565be 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,16 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/gabstv/httpdigest v0.0.0-20200601123255-912d52c2d608 h1:bWFsyrypsqPmph5QgHM5XrNLM2AO1SBc1u90xC58TSg= -github.com/gabstv/httpdigest v0.0.0-20200601123255-912d52c2d608/go.mod h1:HwV0IWP9zs4wP0Gl5zVz5D6CK5uQmDyBfudx9ff9oa8= +github.com/gabstv/httpdigest v0.0.0-20230306144402-1057ac3638b3 h1:iGaBvWPoqaxmJzBGqZTddszzoxpnS0U/olSgclWzGn0= +github.com/gabstv/httpdigest v0.0.0-20230306144402-1057ac3638b3/go.mod h1:HwV0IWP9zs4wP0Gl5zVz5D6CK5uQmDyBfudx9ff9oa8= github.com/gorilla/rpc v1.2.0 h1:WvvdC2lNeT1SP32zrIce5l0ECBfbAlmrmSBsuc57wfk= github.com/gorilla/rpc v1.2.0/go.mod h1:V4h9r+4sF5HnzqbwIez0fKSpANP0zlYd3qR7p36jkTQ= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.6.0 h1:jlIyCplCJFULU/01vCkhKuTyc3OorI3bJFuw6obfgho= github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/utils.go b/utils.go index 4ac3ea2..7a5b9fc 100644 --- a/utils.go +++ b/utils.go @@ -10,14 +10,14 @@ import ( // NewPaymentID64 generates a 64 bit payment ID func NewPaymentID64() string { buf := make([]byte, 8) - rand.Read(buf) + _, _ = rand.Read(buf) return hex.EncodeToString(buf) } // NewPaymentID256 generates a 256 bit payment ID (hex encoded). func NewPaymentID256() string { buf := make([]byte, 32) - rand.Read(buf) + _, _ = rand.Read(buf) return hex.EncodeToString(buf) } diff --git a/wallet/models.go b/wallet/models.go index 28b3267..6ef83c0 100644 --- a/wallet/models.go +++ b/wallet/models.go @@ -579,27 +579,29 @@ type IncomingTransfersRequest struct { // Return transfers for this account. (defaults to 0) AccountIndex uint64 `json:"account_index,omitempty"` // Return transfers sent to these subaddresses. - SubaddrIndices Index `json:"subaddr_indices,omitempty"` - // Enable verbose output, return key image if true. - Verbose bool `json:"verbose,omitempty"` + SubaddrIndices *Index `json:"subaddr_indices,omitempty"` } // IncomingTransfer model type IncomingTransfer struct { // Amount of this transfer. Amount uint64 `json:"amount"` + // BlockHeight is the block height at which this transfer was confirmed. + BlockHeight uint64 `json:"block_height"` + // Frozen indicates whether the output key was frozen by freeze + Frozen bool `json:"frozen"` // Mostly internal use, can be ignored by most users. GlobalIndex uint64 `json:"global_index"` - // Key image for the incoming transfer's unspent output (empty unless verbose is true). + // Key image for the incoming transfer's unspent output. KeyImage string `json:"key_image"` - // Indicates if this transfer has been spent. + // Spent indicates if the output has been spent. Spent bool `json:"spent"` // Subaddress index for incoming transfer. SubaddrIndex Index `json:"subaddr_index"` // Several incoming transfers may share the same hash if they were in the same transaction. TxHash string `json:"tx_hash"` - // Size of transaction in bytes. - TxSize uint64 `json:"tx_size"` + // Unlocked indicates if the output is spendable. + Unlocked bool `json:"unlocked"` } // IncomingTransfersResponse represents the response model for IncomingTransfers diff --git a/wallet/wallet_test.go b/wallet/wallet_test.go index 7e61b17..5789dc5 100644 --- a/wallet/wallet_test.go +++ b/wallet/wallet_test.go @@ -692,45 +692,73 @@ func TestWalletGetBulkPayments(t *testing.T) { func TestWalletIncomingTransfers(t *testing.T) { output := `{ - "id": "0", - "jsonrpc": "2.0", - "result": { - "transfers": [{ - "amount": 60000000000000, - "global_index": 122405, - "key_image": "768f5144777eb23477ab7acf83562581d690abaf98ca897c03a9d2b900eb479b", - "spent": true, - "subaddr_index": { - "major": 0, - "minor": 3 - }, - "tx_hash": "f53401f21c6a43e44d5dd7a90eba5cf580012ad0e15d050059136f8a0da34f6b", - "tx_size": 159 - },{ - "amount": 27126892247503, - "global_index": 594994, - "key_image": "7e561394806afd1be61980cc3431f6ef3569fa9151cd8d234f8ec13aa145695e", - "spent": false, - "subaddr_index": { - "major": 0, - "minor": 3 - }, - "tx_hash": "106d4391a031e5b735ded555862fec63233e34e5fa4fc7edcfdbe461c275ae5b", - "tx_size": 157 - },{ - "amount": 27169374733655, - "global_index": 594997, - "key_image": "e76c0a3bfeaae35e4173712f782eb34011198e26b990225b71aa787c8ba8a157", - "spent": false, - "subaddr_index": { - "major": 0, - "minor": 3 - }, - "tx_hash": "0bd959b59117ee1254bd8e5aa8e77ec04ef744144a1ffb2d5c1eb9380a719621", - "tx_size": 158 - }] - } - }` + "id": "0", + "jsonrpc": "2.0", + "result": { + "transfers": [ + { + "amount": 65523760000, + "block_height": 1555542, + "frozen": false, + "global_index": 5352374, + "key_image": "727bfeb8c28dab760c9c5f646072bd55477557b0c4a7bfd0bdadd751f8120d96", + "pubkey": "b3a500acfa163763ccf6d2c10262294f8c287df3e5cac6309408adf94dc50335", + "spent": true, + "subaddr_index": { + "major": 0, + "minor": 1 + }, + "tx_hash": "4b540773ddf9e819f0df47708f3d3c9f7f62933150b90edc89103d36d42ca4b7", + "unlocked": true + }, + { + "amount": 7989160000, + "block_height": 1764640, + "frozen": false, + "global_index": 8765446, + "key_image": "fd70f985df78f13c8b77836cea91322f20c6f4ea80cff8d3274826008e74cde0", + "pubkey": "8e19b5426dbfe6501f607d68fb1ca1a717f87c950af538cdff96f7e97746822b", + "spent": true, + "subaddr_index": { + "major": 0, + "minor": 0 + }, + "tx_hash": "2aa6843cb5de53f2260bcd222cbf9b90c724b7250d6c0ef039ed1d5ad43fa829", + "unlocked": true + }, + { + "amount": 100000, + "block_height": 2363583, + "frozen": false, + "global_index": 32533306, + "key_image": "0d99656358a8499a78e9baff5e3a5ca5aa19ebf8a9fd21e6edd5d54b3d45c667", + "pubkey": "2feb0deabe3b6cf36b0a5d7addf843c9d585e0f95702e7462b0fac36a2ef7df4", + "spent": false, + "subaddr_index": { + "major": 0, + "minor": 1 + }, + "tx_hash": "e53e9cfb1fe15495e0d6edc94eceb7b9e9471a4eb3a31ddd3e020be12fad5ea1", + "unlocked": true + }, + { + "amount": 10000000000, + "block_height": 2663277, + "frozen": false, + "global_index": 56874042, + "key_image": "4638a83f2d792204575930919ee36f6c4bd039e10bcabaa0fc74dd24e4aab7c9", + "pubkey": "b328b6d97bc6de9ef17b7dfe16147c5a1e395d012f238cee7395c91666ee1822", + "spent": true, + "subaddr_index": { + "major": 0, + "minor": 3 + }, + "tx_hash": "a5fdd2da7f23574a620b0bcddd921b806a397186e61fbe736d5ef7522411aa5f", + "unlocked": true + } + ] + } +}` server := setupServer(t, "incoming_transfers", output) defer server.Close()