Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Geremia on July 24, 2015, 03:22:38 AM



Title: How to send an invalid transaction for testing purposes?
Post by: Geremia on July 24, 2015, 03:22:38 AM
How could I send an invalid transaction—for testing purposes, such as with testnet or regtest?

For example, I would like to to try to double-spend, spend non existent coins, etc.

(cf. the related Bitcoin StackExchange question (https://bitcoin.stackexchange.com/q/38759/4334).)


Title: Re: How to send an invalid transaction for testing purposes?
Post by: DannyHamilton on July 24, 2015, 05:27:08 AM
How could I send an invalid transaction—for testing purposes, such as with testnet or regtest?

For example, I would like to to try to double-spend, spend non existent coins, etc.

(cf. the related Bitcoin StackExchange question (https://bitcoin.stackexchange.com/q/38759/4334).)

Send it where?

Send it from where?

Most node and peer software will prevent the sending or relaying of invalid transactions, therefore you would need to write (or modify) your own node program to allow you to even attempt such a thing.  Then, if you wanted some software to accept the transaction and not simply disconnect and block your custom node, then you would need to write and run your own custom peer to connect to.  At that point you will essentially have created your own altcoin network since nearly every node on the bitcoin network will refuse to communicate with any of your peers once they start receiving invalid transactions from your nodes.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: g3rszpi on July 24, 2015, 07:14:23 AM
How could I send an invalid transaction—for testing purposes, such as with testnet or regtest?

For example, I would like to to try to double-spend, spend non existent coins, etc.

(cf. the related Bitcoin StackExchange question (https://bitcoin.stackexchange.com/q/38759/4334).)
Yeah, sure . For testing purposes :D


Title: Re: How to send an invalid transaction for testing purposes?
Post by: shorena on July 24, 2015, 01:49:53 PM
How could I send an invalid transaction—for testing purposes, such as with testnet or regtest?

For example, I would like to to try to double-spend, spend non existent coins, etc.

(cf. the related Bitcoin StackExchange question (https://bitcoin.stackexchange.com/q/38759/4334).)

A double spend requires you "only" to send a TX with bitcoin core, close it, use pywallet to remove the TX from the wallet.dat, start bitcoin core again and create another TX that spends the exact same input. However - as Danny has noted - this TX will not get accepted by other nodes that already know about the 1st TX - by the time you are done with pywallet close to all nodes - and if you send it to often you will end up on their ban list.

On SE someone suggest you may use createrawtransaction which is correct as it does not require the TX to be valid, there are no sanity checks. You can try to broadcast it unsign, but again other nodes will not accept such a thing. Even if you signed a TX that is using inputs you never received (spend coins that do not exist) I doubt your unmodified bitcoin core will allow you to send it, but even if - or if you followed Dannys advice to write your own node - no other node in the network will accept it. If no other node accepts your TX they also dont spread it, thus all you accomplish with this is that you separate your node from the rest of the network as you (slowly) build up your banscore on other nodes.

Tbh I dont see the testing purpose. One fundamental concept of bitcoin is that no node in the network trusts any other node and is checking everything that is communicated. If you try to broadcast something that makes no sense to other nodes you will not get very far. This is no different on testnet or with regtest enabled. If you check your nodes debug.log you can see it dropping TX from time to time because they are not "standard". A non standard TX however might still get confirmed as they are valid, they are just difficult to send to a miner/pool.

This also sounds to me like an XY Problem[1]. What is the actual problem you try to solve here? What do you want to accomplish?

[1] http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem


Title: Re: How to send an invalid transaction for testing purposes?
Post by: jaydipmodhwadia on July 24, 2015, 09:32:28 PM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?


Title: Re: How to send an invalid transaction for testing purposes?
Post by: Muhammed Zakir on July 25, 2015, 07:51:38 AM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?

It is not plausible.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: Kazimir on July 26, 2015, 08:01:11 PM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?
This is meaningless bogus, complete and utter nonsense. Same as saying someone wire transferred US Dollars to a Litecoin address. Or emailed some bricks of gold to a gmail address.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: TrueBeliever on July 27, 2015, 02:39:53 AM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?
This is meaningless bogus, complete and utter nonsense. Same as saying someone wire transferred US Dollars to a Litecoin address. Or emailed some bricks of gold to a gmail address.

Or someone posted some US quarter coins to store in their Dropbox account.

If someone does manage to send a transaction from the bitcoin blockchain across the ether to the litecoin blockchain I wonder what exchange rate they would get  :P

In all seriousness though it is difficult to counter such nonsensical rumors without more specific information or a link to the OP.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: Amitabh S on July 27, 2015, 02:48:32 AM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?


+1. This is absolute nonsense drool that comes from trolling.
This is meaningless bogus, complete and utter nonsense. Same as saying someone wire transferred US Dollars to a Litecoin address. Or emailed some bricks of gold to a gmail address.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: shorena on July 27, 2015, 08:50:17 AM
Idk if this has anything to do with what the OP says, but I have heard that someone sent some litecoins to a btc Addy... Would this be of consideration?
This is meaningless bogus, complete and utter nonsense. Same as saying someone wire transferred US Dollars to a Litecoin address. Or emailed some bricks of gold to a gmail address.

Or someone posted some US quarter coins to store in their Dropbox account.

If someone does manage to send a transaction from the bitcoin blockchain across the ether to the litecoin blockchain I wonder what exchange rate they would get  :P

In all seriousness though it is difficult to counter such nonsensical rumors without more specific information or a link to the OP.

Yet it still happened. The main problem is that litecoin multisig addresses use the same prefix as bitcoin multisig, thus the address is considered valid on both networks. As they are derived from the same private keys they can still be spend, its just a big mess.

See Dannys post below its more precise and less likely to be understood wrong.

-> https://litecointalk.org/index.php?PHPSESSID=p5vju9t28dhs6hbd7acudemap2&topic=26513.0
-> https://www.reddit.com/r/Bitcoin/comments/24qal5/what_happens_if_i_send_bitcoin_to_a_litecoin/


Title: Re: How to send an invalid transaction for testing purposes?
Post by: DannyHamilton on July 27, 2015, 02:17:16 PM
Yet it still happened.

Sort of, but not really.

It's not like the litecoins show up in the bitcoin wallet.

The litecoins were sent to a valid litecoin address.  It just so happened that the litecoin address was also a valid bitcoin address and that the litecoin address that the litecoins were sent to was copied from an address that was being published for the purpose of receiving bitcoins.

It's a bit like if there were more than one Danny Hamilton in the world.  If I then asked you to send me something in the mail, and you searched for my name on the internet and got the other Danny Hamilton's address, then you would have been sending the mail to "Danny Hamilton", but not to me.

It isn't possible to send litecoins to a bitcoin address.  It is possible to send litecoins to a litecoin address, and it is also possible for the litecoin address to also be a valid bitcoin address.


Title: Re: How to send an invalid transaction for testing purposes?
Post by: tspacepilot on July 28, 2015, 12:19:38 AM
Yet it still happened.

Sort of, but not really.

It's not like the litecoins show up in the bitcoin wallet.

The litecoins were sent to a valid litecoin address.  It just so happened that the litecoin address was also a valid bitcoin address and that the litecoin address that the litecoins were sent to was copied from an address that was being published for the purpose of receiving bitcoins.

It's a bit like if there were more than one Danny Hamilton in the world.  If I then asked you to send me something in the mail, and you searched for my name on the internet and got the other Danny Hamilton's address, then you would have been sending the mail to "Danny Hamilton", but not to me.

It isn't possible to send litecoins to a bitcoin address.  It is possible to send litecoins to a litecoin address, and it is also possible for the litecoin address to also be a valid bitcoin address.

That's really quite fascinating, still.  I didn't find a link to the original description when reading above.  Danny, was this something that you were playing with?

EDIT: sorry, i see the link in Shorena's post now, following up myself.