AegeusCoin / aegeus-ui

0 stars 2 forks source link

Find address may lead to IndexOutOfBoundsException #61

Closed tdiesler closed 1 year ago

tdiesler commented 5 years ago
Nov 29, 2018 6:17:03 AM wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient$TransactionWrapper raw
WARNING: RPC Query Failed (method: getrawtransaction, params: [8704607ad618134d978b4137d2c06519318f342a832517d0d2989e5a5a8afdc6, 1], response code: 500 responseMessage Internal Server Error, response: {"result":null,"error":{"code":-5,"message":"No information available about transaction"},"id":"1"}

ERROR executing request
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at io.nessus.AbstractWallet.listLockUnspent(AbstractWallet.java:398)
    at io.nessus.core.ipfs.impl.DefaultContentManager.listLockedAndUnlockedUnspent(DefaultContentManager.java:1100)
    at io.nessus.core.ipfs.impl.DefaultContentManager.findAddressRegistation(DefaultContentManager.java:469)
    at io.nessus.ipfs.jaxrs.JAXRSResource.findAddressRegistation(JAXRSResource.java:74)
tdiesler commented 5 years ago

This is likely caused by https://github.com/AegeusCoin/aegeus/issues/13

When running a new aegd image (which will create a new wallet) and then import a known private key. I see ...

root@1e9e7609605c:/# aegeus-cli listunspent
[
    {
        "txid" : "a1971981edf2f486dbbbefbe920b269277bab0120006a730f7de35159322ac28",
        "vout" : 1,
        "address" : "AJG36ywiYJnxJLdRDw8nzHUqKbAujmjvpX",
        "account" : "Bob",
        "scriptPubKey" : "76a9141b43cae0b04f4e5c9352e6d923a00b5007c9849788ac",
        "amount" : 0.00054600,
        "confirmations" : 11077,
        "spendable" : true
    },
    {
        "txid" : "ad088403c81e606e6015edb44ae84e5ee1c236bf1df14c1c4d4e27b580aa2f70",
        "vout" : 1,
        "address" : "AJG36ywiYJnxJLdRDw8nzHUqKbAujmjvpX",
        "account" : "Bob",
        "scriptPubKey" : "76a9141b43cae0b04f4e5c9352e6d923a00b5007c9849788ac",
        "amount" : 0.00054600,
        "confirmations" : 11223,
        "spendable" : true
    },
    {
        "txid" : "c27abede70a8b540ccb644829b0b70fcaa4facaebe4763ddb060848cf84698c8",
        "vout" : 0,
        "address" : "AJG36ywiYJnxJLdRDw8nzHUqKbAujmjvpX",
        "account" : "Bob",
        "scriptPubKey" : "76a9141b43cae0b04f4e5c9352e6d923a00b5007c9849788ac",
        "amount" : 0.13875760,
        "confirmations" : 11077,
        "spendable" : true
    },
    {
        "txid" : "ce9348167451bd6a34ad029976f6d8cda0791a0c6ae7811cf9cb7302f8f21fc2",
        "vout" : 1,
        "address" : "AJG36ywiYJnxJLdRDw8nzHUqKbAujmjvpX",
        "account" : "Bob",
        "scriptPubKey" : "76a9141b43cae0b04f4e5c9352e6d923a00b5007c9849788ac",
        "amount" : 0.00054600,
        "confirmations" : 11223,
        "spendable" : true
    }
]
tdiesler commented 5 years ago

Adding some more debug logging ...

The wallet reports

root@1e9e7609605c:/# aegeus-cli listlockunspent
[
    {
        "txid" : "853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5",
        "vout" : 1
    }
]

Adding this code ...

    /**
     * [FIXME #13] listlockunspent may return stale data
     * https://github.com/AegeusCoin/aegeus/issues/13
     */
    @Override
    protected Tx getLockedTransaction(String txId) {
        Tx result = null;
        try {
            LOG.warn("Getting Tx: {}", txId);
            result = super.getTransaction(txId);
            LOG.warn("Got Tx: {}", result);
        } catch (BitcoinRPCException ex) {
            LOG.warn("Cannot get Tx: " + txId, ex);
            if (ex.getMessage().contains("Invalid or non-wallet transaction id")) {
                return null;
            }
            throw ex;
        }
        return result;
    }

I see ...

Getting Tx: 853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5
Nov 29, 2018 6:44:36 AM wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient$TransactionWrapper raw
WARNING: RPC Query Failed (method: getrawtransaction, params: [853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5, 1], response code: 500 responseMessage Internal Server Error, response: {"result":null,"error":{"code":-5,"message":"No information available about transaction"},"id":"1"}

Got Tx: [tx=853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5, vin=0, vout=0]
ERROR executing request
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:657)
    at java.util.ArrayList.get(ArrayList.java:433)
    at io.nessus.AbstractWallet.listLockUnspent(AbstractWallet.java:398)
    at io.nessus.core.ipfs.impl.DefaultContentManager.listLockedAndUnlockedUnspent(DefaultContentManager.java:1100)
    at io.nessus.core.ipfs.impl.DefaultContentManager.findAddressRegistation(DefaultContentManager.java:469)
    at io.nessus.ipfs.jaxrs.JAXRSResource.findAddressRegistation(JAXRSResource.java:74)
tdiesler commented 5 years ago

Oh dear, even a manual unlock does not fix it

root@1e9e7609605c:/# aegeus-cli lockunspent false '[{"txid":"853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5","vout":1}]'
true
root@1e9e7609605c:/# aegeus-cli listlockunspent
[
    {
        "txid" : "853e910bedb7c8213bc93cab7e8337e0a59731db1e0c8968d2e19355d850bdc5",
        "vout" : 1
    }
]
tdiesler commented 5 years ago

Related to https://github.com/Polve/JavaBitcoindRpcClient/issues/88

tdiesler commented 1 year ago

out-of-date