Bitcoin Forum
May 04, 2024, 06:13:47 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [18] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
Author Topic: 300 BTC Coding Contest: Distributed Exchange (MasterCoin Developer Thread)  (Read 129135 times)
This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic.
Bitoy
Sr. Member
****
Offline Offline

Activity: 449
Merit: 250


View Profile
November 05, 2013, 05:31:44 AM
 #341

Hi Tachikoma


Buyer 1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk posted a
Buy   20 Test MSC for  .00002
TxID: 33644e6f24b29e1ef170d78ff04eab6f7e19368908edc6d477f9902697a71d67

But there is no confirmed payment transaction.   

When buyer posted a sell Transaction (.11 and .9 Test MSC) it is invalid because there was no payment yet for the first transaction.


After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed





Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714846427
Hero Member
*
Offline Offline

Posts: 1714846427

View Profile Personal Message (Offline)

Ignore
1714846427
Reply with quote  #2

1714846427
Report to moderator
Bitoy
Sr. Member
****
Offline Offline

Activity: 449
Merit: 250


View Profile
November 05, 2013, 05:36:32 AM
 #342


Hey Grazcoin,

You'll need to look at your multi-packet handling.  From your de-obfuscated packet It looks like you're SHA hashing the second packet only once.  You'll need to hash seqnum times (so in this case 2).

In terms of a 'definition' for Class B I think the closest thing we have at the mo is my suggested amendment here

Hope that helps Smiley

Grazcoin,

You might want to try convert the first hash to uppercase letters before hashing it again.

hashString1 = the first hash string
ex
Dim HashString2 As String = GetHash(hashString1.ToUpper)

This worked for me.

grazcoin
Sr. Member
****
Offline Offline

Activity: 284
Merit: 250



View Profile
November 05, 2013, 07:38:37 AM
 #343


Hey Grazcoin,

You'll need to look at your multi-packet handling.  From your de-obfuscated packet It looks like you're SHA hashing the second packet only once.  You'll need to hash seqnum times (so in this case 2).

In terms of a 'definition' for Class B I think the closest thing we have at the mo is my suggested amendment here

Hope that helps Smiley

Grazcoin,

You might want to try convert the first hash to uppercase letters before hashing it again.

hashString1 = the first hash string
ex
Dim HashString2 As String = GetHash(hashString1.ToUpper)

This worked for me.



Thanks guys!
That's exactly what I needed Smiley


Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 09:18:35 AM
 #344

Hi Tachikoma

Buyer 1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk posted a
Buy   20 Test MSC for  .00002
TxID: 33644e6f24b29e1ef170d78ff04eab6f7e19368908edc6d477f9902697a71d67

But there is no confirmed payment transaction.   

When buyer posted a sell Transaction (.11 and .9 Test MSC) it is invalid because there was no payment yet for the first transaction.

After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed


Thanks for checking my data. I'm not sure I understand you correctly though. Could you try explaining it with examples what went wrong?

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
grazcoin
Sr. Member
****
Offline Offline

Activity: 284
Merit: 250



View Profile
November 05, 2013, 10:08:58 AM
 #345

I am adding now the parsing of sell/buy offers to mastercoin-tools, and I start with this tx:
https://blockchain.info/tx/49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34

Code:
$ python msc_parse.py -t 49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34 -d
[D] main: multisig tx found: 49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34
[I] parse_multisig: ['0001000000140000000200000000773594000000000000004e2006000000000000', '000200271000000000000000000000000000000000000000000000000000000000']
[I] parse_multisig: {'tx_hash': '49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34', 'tx_type_str': 'Sell offer', 'formatted_bitcoin_amount_desired': '0.00020000', 'currencyId': '00000002', 'currency_str': 'Test Mastercoin', 'tx_method_str': 'multisig', 'amount': '0000000077359400', 'fee_required': '002710', 'block_time_limit': '06', 'formatted_amount': '20.00000000', 'bitcoin_amount_desired': '0000000000004e20', 'formatted_block_time_limit': '6', 'baseCoin': '00', 'formatted_fee_required': '0.00010000', 'dataSequenceNum': '01', 'transactionType': '00000014'}

I compare to http://mastercoin-explorer.com/transactions/49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34 and it seems that most fields get parsed well, except for:
* Price per coin 0.00001 =>1000 = 0x3E8 ( I don't see any 3e8 on the first or second hexdata)

And I would like to discuss the amount of bytes allocated to each field:
* Bitcoin amount desired - data_script[36:52] (instead of the original "simple send" padding - no problem)
* Fee required - second_data_script[4:10] (limited with 0.16777215 BTC - seems enough)
* Block time limit - data_script[52:54] (limited with 255 blocks which is around 1.77 days - very short)


EDIT:
Price per coin is calculated from "amount" and "bitcoin amount desired".
My only question is not about "block time limit". Isn't it too short?


zathras
Sr. Member
****
Offline Offline

Activity: 266
Merit: 250



View Profile
November 05, 2013, 10:15:28 AM
 #346

I am adding now the parsing of sell/buy offers to mastercoin-tools, and I start with this tx:
https://blockchain.info/tx/49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34

Code:
$ python msc_parse.py -t 49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34 -d
[D] main: multisig tx found: 49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34
[I] parse_multisig: ['0001000000140000000200000000773594000000000000004e2006000000000000', '000200271000000000000000000000000000000000000000000000000000000000']
[I] parse_multisig: {'tx_hash': '49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34', 'tx_type_str': 'Sell offer', 'formatted_bitcoin_amount_desired': '0.00020000', 'currencyId': '00000002', 'currency_str': 'Test Mastercoin', 'tx_method_str': 'multisig', 'amount': '0000000077359400', 'fee_required': '002710', 'block_time_limit': '06', 'formatted_amount': '20.00000000', 'bitcoin_amount_desired': '0000000000004e20', 'formatted_block_time_limit': '6', 'baseCoin': '00', 'formatted_fee_required': '0.00010000', 'dataSequenceNum': '01', 'transactionType': '00000014'}

I compare to http://mastercoin-explorer.com/transactions/49f3efe0eba50ea08220c27d3c8174c5fa8a7782615823ab256859562cbd4a34 and it seems that most fields get parsed well, except for:
* Price per coin 0.00001 =>1000 = 0x3E8 ( I don't see any 3e8 on the first or second hexdata)

And I would like to discuss the amount of bytes allocated to each field:
* Bitcoin amount desired - data_script[36:52] (instead of the original "simple send" padding - no problem)
* Fee required - second_data_script[4:10] (limited with 0.16777215 BTC - seems enough)
* Block time limit - data_script[52:54] (limited with 255 blocks which is around 1.77 days - very short)


There is no price per coin in the transaction data, only the number for sale and a total price.  We get price per coin by total price / number for sale.

For the block time limit - this is not how long the sell offer is valid for, it's how long the buyer has to make payment after their accept/'Purchase Offer' is accepted & first in a block.  I don't think too many sellers are going to want to post a sell offer allowing more than 1.77 days for the buyer to make payment Smiley During testing between 6 and 10 has been a good value.


Smart Property & Distributed Exchange: Master Protocol for Bitcoin
grazcoin
Sr. Member
****
Offline Offline

Activity: 284
Merit: 250



View Profile
November 05, 2013, 11:28:09 AM
 #347

There is no price per coin in the transaction data, only the number for sale and a total price.  We get price per coin by total price / number for sale.

For the block time limit - this is not how long the sell offer is valid for, it's how long the buyer has to make payment after their accept/'Purchase Offer' is accepted & first in a block.  I don't think too many sellers are going to want to post a sell offer allowing more than 1.77 days for the buyer to make payment Smiley During testing between 6 and 10 has been a good value.

Thanks for clarifying.

As I understand the chosen procedure, in order to sell mastercoins, we need 3 tx:
1. Sell offer.
2. Sell accept (that's a better name than purchase offer).
3. Actual payment.

If the buyer doesn't pay within the allowed time, the sell order simply continues (and the next buyer gets the mastercoins).
If there is an earlier buyer (who actually pays) all later accepts are ignored.


Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 12:34:40 PM
 #348

There is no price per coin in the transaction data, only the number for sale and a total price.  We get price per coin by total price / number for sale.

For the block time limit - this is not how long the sell offer is valid for, it's how long the buyer has to make payment after their accept/'Purchase Offer' is accepted & first in a block.  I don't think too many sellers are going to want to post a sell offer allowing more than 1.77 days for the buyer to make payment Smiley During testing between 6 and 10 has been a good value.

Thanks for clarifying.

As I understand the chosen procedure, in order to sell mastercoins, we need 3 tx:
1. Sell offer.
2. Sell accept (that's a better name than purchase offer).
3. Actual payment.

If the buyer doesn't pay within the allowed time, the sell order simply continues (and the next buyer gets the mastercoins).
If there is an earlier buyer (who actually pays) all later accepts are ignored.



Basically, yes.

Just know that you don't have to buy a whole Purchase Offer in one go. You can just buy a couple of coins which means that the next person buying might also get the coins if there were enough.

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
Bitoy
Sr. Member
****
Offline Offline

Activity: 449
Merit: 250


View Profile
November 05, 2013, 12:59:27 PM
 #349

Hi Tachikoma

Buyer 1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk posted a
Buy   
TxID: 33644e6f24b29e1ef170d78ff04eab6f7e19368908edc6d477f9902697a71d67

But there is no confirmed payment transaction.   

When buyer posted a sell Transaction (.11 and .9 Test MSC) it is invalid because there was no payment yet for the first transaction.

After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed


Thanks for checking my data. I'm not sure I understand you correctly though. Could you try explaining it with examples what went wrong?


I can't find the transaction where    
1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk sent  .00002 BTC to  16rAwebBXhJAM9ALf3fLFbaHKz24r2o3UN
If there is a payment the rest of the transaction will be valid.   It could be a bug in my implementation.

Here is an example
UserA places an advertisement to sell
UserB accepts UserA's  offer
(Note: UserB has not paid UserA)

UserB places an advertisement to sell
UserC accepts UserB's offer
UserC pays UserB


Since UserB has not paid UserA the transaction of UserB with UserC is invalid.








prophetx
Legendary
*
Offline Offline

Activity: 1666
Merit: 1010


he who has the gold makes the rules


View Profile WWW
November 05, 2013, 01:06:17 PM
 #350

Offer cancellation

Is there something for this, to pull back an offer?  Maybe I missed it.  Or would one need to accept ones own offer in orer to cancel it it out once the offer hits the blockchain?
Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 01:36:56 PM
 #351

Offer cancellation

Is there something for this, to pull back an offer?  Maybe I missed it.  Or would one need to accept ones own offer in orer to cancel it it out once the offer hits the blockchain?

Make a new Selling Offer and set the amount to zero Smiley

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 01:40:48 PM
 #352

Hi Tachikoma

Buyer 1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk posted a
Buy   
TxID: 33644e6f24b29e1ef170d78ff04eab6f7e19368908edc6d477f9902697a71d67

But there is no confirmed payment transaction.   

When buyer posted a sell Transaction (.11 and .9 Test MSC) it is invalid because there was no payment yet for the first transaction.

After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed


Thanks for checking my data. I'm not sure I understand you correctly though. Could you try explaining it with examples what went wrong?


I can't find the transaction where    
1EdAjiApS5cCpHdH4RKPMab1xmMVRWjLvk sent  .00002 BTC to  16rAwebBXhJAM9ALf3fLFbaHKz24r2o3UN
If there is a payment the rest of the transaction will be valid.   It could be a bug in my implementation.

Here is an example
UserA places an advertisement to sell
UserB accepts UserA's  offer
(Note: UserB has not paid UserA)

UserB places an advertisement to sell
UserC accepts UserB's offer
UserC pays UserB


Since UserB has not paid UserA the transaction of UserB with UserC is invalid.

Hmm, I'm afraid that perhaps my implementation actually counts the "Purchase Offer" as the actual payment. Since the amounts are so small it might have considered the output amount of the Mastercoin payment as payment since we use the reference address. Normally this shouldn't happen since the amounts will be much larger. I will check my code to see how it matches based on block number.

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
prophetx
Legendary
*
Offline Offline

Activity: 1666
Merit: 1010


he who has the gold makes the rules


View Profile WWW
November 05, 2013, 01:53:02 PM
 #353

Offer cancellation

Is there something for this, to pull back an offer?  Maybe I missed it.  Or would one need to accept ones own offer in orer to cancel it it out once the offer hits the blockchain?

Make a new Selling Offer and set the amount to zero Smiley

Is that always the case?

So one could not have 2 sell offers say at different prices from the same address?  Each consequetive offer replaces the prior? 

For example, I have 100 msc, and put an offer to sell 50 at 1 btc each.

If I want to cancel this then I would make another offer for 0 at x btc.

But that precludes being able to have one offer of 50 msc at 1 btc each and another offer at 50 msc at 0.9 btc each.  Unless I move 50 msc to another address first.

I guess I need to read the spec again.
Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 02:04:31 PM
 #354

You can only have one offer per address. Reading the paper will make this clear. You can easily have multiple addresses though, so it doesn't have to be a real problem.

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 05, 2013, 03:46:50 PM
 #355


After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed


Looks like this transaction also didn't pass

The payment was made after the Max Block Limit of 267486.

Transaction is also invalid. 

I don't think so. The payment was one block later then the "Purchase Offer"

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
Bitoy
Sr. Member
****
Offline Offline

Activity: 449
Merit: 250


View Profile
November 05, 2013, 03:58:28 PM
 #356


After reparsing I only found one valid purchase

Buy .2 Test MSC for .003232 BTC
TxID: c7103de53a8ea3a20cec9a74543132f98302f75ab1868092e911dd5516f322a5
Confirm Payment TxID: 2bb54346f7d0ddfcb084451227089665bc1a7ebf8f0a9338d14d713592c268ed


Looks like this transaction also didn't pass

The payment was made after the Max Block Limit of 267486.

Transaction is also invalid. 

I don't think so. The payment was one block later then the "Purchase Offer"

You are correct.   Payment is before block limit of 267486.   Site updated.  Thanks =)

http://mymastercoins.com/Orders.aspx?CurrencyID=2
ASIC-8Tile
Sr. Member
****
Offline Offline

Activity: 279
Merit: 250


View Profile
November 06, 2013, 02:12:36 AM
 #357

Please PM me if SOMEONE has extra Test Mastercoins they can spare...

Tachikoma
Hero Member
*****
Offline Offline

Activity: 938
Merit: 1000



View Profile WWW
November 06, 2013, 08:42:02 AM
 #358

Please PM me if SOMEONE has extra Test Mastercoins they can spare...

Give me an address and I will send you some.

Electrum: the convenience of a web wallet, without the risks | Bytesized Seedboxes BTC/LTC supported
4nil
Newbie
*
Offline Offline

Activity: 2
Merit: 0



View Profile
November 06, 2013, 02:46:32 PM
 #359

I was wondering, would it be possible to build upon the same mechanism for BTC-MSC exchange and add support for LTC/other alt-chain exchanging? I don't use LTC or have any but I do know a decent segment would find it useful to be able to trade back and forth between alt currencies. It could be a good, quick, and easy proof-of-concept and validation for Mastercoin to be used to trade other cryptocurrencies around for each other if there was a way to parse/manipulate two blockchains at once.

Actually thinking about it, it probably would be trivial. If you can do it with BTC I don't see why LTC would be difficult but I'm not an expert.

I think once MSC to BTC is working then LTC and the other altcoins ought to be next.


LTC will have to wait until we've got LTC tokens stored in the bitcoin block chain. That will either be user-backed smart property, or escrow-backed tokens later. We can do BTC/MSC now because we are living in the BTC block chain.

i'm new to MSC, when i finished reading your spec i got one question,
why not issue MSC as smart property at the very beginning of genesis block rather than sending people MSC from your account.
with my understanding, it could be 2 steps.
1. issue smart property.
2. selling part of shares to raise money.
is it possible to create MSC as the first smart property in MSC protocol?
4nil
Newbie
*
Offline Offline

Activity: 2
Merit: 0



View Profile
November 06, 2013, 03:43:26 PM
 #360

Please PM me if SOMEONE has extra Test Mastercoins they can spare...

Give me an address and I will send you some.

i've tried bitcoin-qt to finish a offer, finally failed Sad
could you send me some for test, my address: 14niL1KeoNafvXYzcn9Win7avBkXQ7U2g2, thanks.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 [18] 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 »
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!