omnicore: Error choosing inputs for the send transaction

When I was planning to send USDT, there was an error. I am sure my balance of USDT&BTC is adequate.

$ ./omnicore-cli omni_funded_send "mrAVAPxdQEZxFkunh56skB6sgJa6vrfrpo" "msJ2h47ZrxFJjksVvPy8ik4h2HFfa9W1zV" 31 "100.01" "mpaumxor659PhoJhXp1VCVHVwbFCZSRmuf"
error code: -212
error message:
Error choosing inputs for the send transaction

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 37 (4 by maintainers)

Most upvoted comments

I’ve come back to this thread a few times because I was totally stumped, and think I may have figured out why a lot more people are seeing this than would be expected (including me). Pardon me if the language is a bit imprecise:

You need UTXO’s in an OMNI address to send OMNI-layer transactions (not super surprising) out of that address.

In practice, what this means is that if: you receive some USDT to a fresh address, and want to send some of the USDT out of that address you can do a “funded send” to pay the transaction fee out of a “fee address” you have (great!). However, what you then wind up with is an address that has some OMNI but no UTXO’s (you consumed it in the previous transaction). So now, even though you can pay the fee to send the remaining USDT from that address to another using “funded_send”, you can’t actually compose a transaction out of that address, since you have consumed the UTXO. So now you need to send some bitcoin (or whatever you want to do) to that address again to get it a UTXO, with which it can compose the funded_send transaction.

  1. Receive 10 OMNI to fresh address abdce...
  2. Send 5 OMNI to another address using omni_funded_send - ✅
  3. Try to send the remaining 5 OMNI to another address using omni_funded_send - ❗️
    • You will get the error -212 because it can’t find a UTXO to send that last 5 OMNI on (regardless of whether you have BTC in the fee address)

It seems like a great added feature of the OMNI protocol would be to, when composing a funded_send that is not going to send ALL the omni properties from a given address, address a UTXO back to the origin - conceptually like a “change” transaction…

This problem has been solved. When using the method omni_funded_send to send tokens, fromAddress should have a bit of btc.It means that the “feeaddress” does not pay all the fees. As the error resp said, “All bitcoins from the sender are consumed and if there are bitcoins missing, they are taken from the specified fee source.”

In my case BTC’s UTXO was present in listlockunspent outputs list instead of expected listunspent, and simple lockunspent true command helped me

I confirm this issue still happen.

I confirm this issue still happen. if the address have no UTXO, it can’t send any coin.

@WilliamXie9 can you please specify steps how did you do that? Using raw-transaction RPCs, right?

@dmitryrn sure `

    val network = TestNet3Params.get()
    var client = OmniCLIClient(network, URI("http://xxx.xxx.xxx.xxx:xxx"), "username", "password")
    var client2 = BitcoinJSONRPCClient(URL("http://name:password@xx.xx.xx.xx:xx/"))


    // 1 list unspent outputs
    client2.importAddress("mznoRw5ingAqQAXEhxxxxzAkRgc2aAC7", "test", false)
    var feeUtxoList = client2.listUnspent(0, 999999, "mznoRw5ingAqQAXEhxxxxzAkRgc2aAC7")
    var senderUtxoList = client2.listUnspent(0, 999999, "mmf3TtdKNHdV7byWxxxxxGbiRCVrVnB3Bd")

    // 3 construct transaction base, add sender address
    var tx1 = Transaction(network)
    tx1.addInput(Sha256Hash.wrap(senderUtxoList[0].txid()),
            senderUtxoList[0].vout().toLong(),
            Script(NumericUtil.hexToBytes(senderUtxoList[0].scriptPubKey())))


    // 3.2 add fee address
    tx1.addInput(Sha256Hash.wrap(feeUtxoList[0].txid()),
            feeUtxoList[0].vout().toLong(),
            Script(NumericUtil.hexToBytes(feeUtxoList[0].scriptPubKey())))

    // 4 attach payload output
    var op = BigDecimal(0.50700001).times(BigDecimal(10).pow(8)).toLong()
    tx1.addOutput(Coin.valueOf(0), Script(Hex.decode("6a146f6d6e69" + String.format("%016x", 1) + String.format("%016x", op))))

    // 5 attach reference/receiver output
    tx1.addOutput(Coin.valueOf(0), Address.fromString(network, "mzwB28AkTn1A2wUd7xxxxxaZsPxMFc3FnY"))

    // 6 specify miner fee and attach change output
    tx1.addOutput(Coin.valueOf(6700000), Address.fromString(network, "mznoRw5ingAqQAXEhxxxxzAkRgc2aAC7"))

    // 7 sign transaction
    // a: sender sign
    var ecKey = DumpedPrivateKey.fromBase58(network, "cQRYVgbejCXxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxm8oHCMik9WS").key
    var scriptPubKey = ScriptBuilder.createOutputScript(org.bitcoinj.core.Address.fromString(network, "mmf3TtdKNHdV7byWxxxxxGbiRCVrVnB3Bd"))
    var hash = tx1.hashForSignature(0, scriptPubKey, Transaction.SigHash.ALL, false)
    var txSig = TransactionSignature(ecKey.sign(hash), Transaction.SigHash.ALL, false)
    tx1.inputs[0].scriptSig = ScriptBuilder.createInputScript(txSig, ecKey)
    // b: fee address sign
    var ecKey2 = DumpedPrivateKey.fromBase58(network, "cQHGQGVFMjTEixxxxxxxxxxxxxxxxxxxxxxxxxxL2bwdqK6dQoMh").key
    var scriptPubKey2 = ScriptBuilder.createOutputScript(org.bitcoinj.core.Address.fromString(network, "mznoRw5ingAqQAXEhxxxxzAkRgc2aAC7"))
    var hash2 = tx1.hashForSignature(1, scriptPubKey2, Transaction.SigHash.ALL, false)
    var txSig2 = TransactionSignature(ecKey2.sign(hash2), Transaction.SigHash.ALL, false)
    tx1.inputs[1].scriptSig = ScriptBuilder.createInputScript(txSig2, ecKey2)


    // 8 broadcast transaction
    var newBroadcastTxId = client.sendRawTransaction(NumericUtil.bytesToHex(tx1.bitcoinSerialize()))`

Still happen. I try to construct omni_funded_send transaction without RPC API, and I found the omni_funded_send API actually add new inputs for paying fee. Construct that transaction, you need the inputs for sender address, mean you need utxo of sender address, but this utxo‘s amount can be 0 which comes from previous transaction - like user deposit. This is the transaction i construct: https://www.blockchain.com/btctest/tx/03d56a0c18fd115c5fdee42e62c544dfa3194e1ff6102621750985da39a4cb60 FYI: https://medium.com/omnilayer/introducing-funded-omni-layer-transactions-or-how-exchanges-can-save-money-f3f04161a6af