appendrawchange throws Insufficient funds, why?

+1 vote

Okay so I have created a transaction like this>
createrawtransaction '[{"txid":"ba747b05dfd28e2756f13c377b51f711966874f26189e018d648ec9558ad11f8","vout":0}]' '{"1ZiUq8ssyK4sMKD4Dt1Tv1V7k4TDjh5aXzXhme":{"F":1.0}}'

signed it like this

signrawtransaction 0100000001f811ad5895ec48d618e08961f274689611f7517b373cf156278ed2df057b74ba0000000000ffffffff0100000000000000003176a914f20e9ec3456967efcfb006cef2d180ae5ffab46e88ac1673706b710b0000000e020000ba7401000000000000007500000000

But when I append it like this.

The 1ZiUq8ssyK4sMKD4Dt1Tv1V7k4TDjh5aXzXhme is an external node' public key.

The 1Ynn2CyNSQoeHrsXZqvuygyVs9pBPfydoRhS9X is the one issuing this transactions public key.

appendrawchange 0100000001f811ad5895ec48d618e08961f274689611f7517b373cf156278ed2df057b74ba000000006b483045022100ca7aa8c87a8a3a9c73446afe2838a370a69297a0a6c37107effefe402561745b02207682f47e4c8d8708a2b94ced7b22654da1c5131968e018452bbe8d892751d02b0121037a6acdd32387f4fb6b4b48359c3be813f82861f926224b2785077aca2b872e82ffffffff0100000000000000003176a914f20e9ec3456967efcfb006cef2d180ae5ffab46e88ac1673706b710b0000000e020000ba7401000000000000007500000000 1Ynn2CyNSQoeHrsXZqvuygyVs9pBPfydoRhS9X 0 

I get this error: Insufficient funds, output asset value is higher than input
How can this be true? I have millions of F assets in my wallet and I just want to send 1 by raw transaction. My goal is to find out if I can somehow make sure that the transaction would only be executable once and a racecondition would just end up failing.

 

Any idea why I get this error?

asked Mar 10, 2016 by patr0805

2 Answers

0 votes
 
Best answer

OK, we found the bug which is causing this - appendrawchange does not work properly if one of the inputs is an asset issuance transaction. We'll fix this in the next alpha. In the meantime, you can work around the problem by using preparelockunspent(from) to move the full asset amount out of the issuance transaction into a new transaction, and then send it on from there using createrawtransaction / appendrawchange. Thanks for reporting this.

answered Mar 16, 2016 by MultiChain
selected Mar 16, 2016 by patr0805
This has been fixed in alpha 19, just released.
0 votes

You need to call appendrawchange before calling signrawtransaction - does that help?

answered Mar 10, 2016 by MultiChain
Sorry for the long delay before replying.
Anyway no it didn't work, I think I will post the exact list of commands from creation of the asset to the transaction.
Link to log: http://hardmech.com/sample.txt. *Notice that in this sample I am using the same node and sending from one address in the same wallet to another. In the post above I had access to two computers (each there own node) and I ran into the same error.
Are you using a native currency? Two more pieces of information would help us diagnose this: (a) the output from getblockchainparams, and (b) the output of calling decoderawtranasction on the big hexadecimal response from createrawtransaction.
And of course which MultiChain version you are using.
**JUst for note, use my sample.txt and not my original post.

Version: MultiChain Core Daemon build 1.0 alpha 16 protocol 10003
Native currency? Well I am making my own currency asset called "S" for educational purposes.
{
    "txid" : "e13abe7fcaed23ddcd3bc590090335b064985536baa4a84e4e20e1bbe207bbeb",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "101dea3d2d24c773227856b95d7a24f5d67a2b7ed48c8635ea7b4af6baad0dc6",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "",
                "hex" : ""
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00000000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 537b2af00c5d79b017e64d15a89d8b9b485578d5 OP_EQUALVERIFY OP_CHECKSIG 73706b710a00000009010000101d0100000000000000 OP_DROP",
                "hex" : "76a914537b2af00c5d79b017e64d15a89d8b9b485578d588ac1673706b710a00000009010000101d010000000000000075",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1CHQaVvuf5LvG5fjSxBvcssFeBPRz8RbtaN6CA"
                ]
            },
            "assets" : [
                {
                    "name" : "S",
                    "issuetxid" : "101dea3d2d24c773227856b95d7a24f5d67a2b7ed48c8635ea7b4af6baad0dc6",
                    "assetref" : "10-265-7440",
                    "qty" : 1.00000000,
                    "raw" : 1
                }
            ],
            "permissions" : [
            ]
        }
    ],
    "data" : [
    ]
}

Why would appendrawchange ever say this? The API doc says: Any assets or native currency in the transaction inputs which are not claimed in the outputs will be sent to address. I would simply think that I should make this command to make it throw the remainder back to the original source. Allthough I dont get why this would even be nessesary in this case, after all I already specified in createrawtransaction that I wanted to send just 1 S to the given destination.. there shouldnt be any remainder there, unless it counts that having 1000 S means it should send 999 back instead of just letting it be..??
Thanks - it does indeed look like a bug and we'll check into it. In the meantime the reason why you need to add the change output is that this is the transaction model for bitcoin-style blockchains - all inputs to a transaction are 'spent' so you need to send the unsent amount back to the original sender in a second output.
We found the problem - answer above. Thanks.
...