|
@@ -37,7 +37,7 @@ Suppose Alice has 100 PASC and Bob has 1 BTC, and they wish to perform an atomic
|
|
|
|
|
|
4. Alice owns account **X** and deposits 100 PASC into **X** and sets it for Private Sale to Bob as follows:
|
|
4. Alice owns account **X** and deposits 100 PASC into **X** and sets it for Private Sale to Bob as follows:
|
|
|
|
|
|
- - X.Type = ***\<Hash Locked>***
|
|
|
|
|
|
+ - X.State = ***\<HLTC_A>***
|
|
- X.Data = **CODE**
|
|
- X.Data = **CODE**
|
|
- X.BuyerKey = **B**
|
|
- X.BuyerKey = **B**
|
|
- X.SalePeriod = **3 weeks** ;/ specified in block numbers
|
|
- X.SalePeriod = **3 weeks** ;/ specified in block numbers
|
|
@@ -95,25 +95,47 @@ _Notice that Alice's offer to Bob was locked for 3 weeks, yet Bob's offer to Ali
|
|
|
|
|
|
The following changes are required to implement this type of HLTC in PascalCoin.
|
|
The following changes are required to implement this type of HLTC in PascalCoin.
|
|
|
|
|
|
-#### Operation Update(s): OP_BuyAccount and OP_Transaction
|
|
|
|
|
|
+#### New Account State
|
|
|
|
|
|
-The consensus rule when purchasing an account listed for private sale requires a minor change. This rule applied for both OP_BuyAccount and OP_Transaction.
|
|
|
|
|
|
+A new TAccountState called ```as_HLTC_PASA``` is required.
|
|
|
|
|
|
```pascal
|
|
```pascal
|
|
-let S = target PASA
|
|
|
|
-let T = purchasing operation (can be either OP_BuyAccount or OP_Transaction)
|
|
|
|
|
|
|
|
-... implement existing consensus rules ...
|
|
|
|
|
|
+TAccountState = (as_Unknown, as_Normal, as_ForSale, as_HLTC_PASA);
|
|
|
|
|
|
-// PIP-0032A: Atomic Swap
|
|
|
|
-if (S.SaleType = PrivateSale) and (S.Type = <HashLocked>) then begin
|
|
|
|
- // It's an atomic swap private sale, sender must provide secret
|
|
|
|
- if SHA2_256(T.Payload) <> S.Data then
|
|
|
|
- Error "Hash-locked accounts require correct hash pre-image when purchasing. Purchaser did not provide correct hash pre-image.";
|
|
|
|
|
|
+```
|
|
|
|
+
|
|
|
|
+This new state will result in behaviour identical to ```as_ForSale``` except with an additional consensus rule.
|
|
|
|
+
|
|
|
|
+#### Operation Update(s): OP_Transaction, OP_BuyAccount
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+The consensus rules for OP_Data needs updating to execute ```as_HLTC_PASA``` is identical to state ```as_ForSale``` but with the following additional checks
|
|
|
|
+
|
|
|
|
+```pascal
|
|
|
|
+
|
|
|
|
+let A = target PASA
|
|
|
|
+let O = purchasing operation (can be either OP_BuyAccount or OP_Transaction)
|
|
|
|
+
|
|
|
|
+...... same consensus rules for as_ForSale (in private mode) ....
|
|
|
|
+
|
|
|
|
+ // PIP-0032A: Atomic Swap
|
|
|
|
+if (A.accountInfo.state = as_HLT as_HLTC_PASA: begin
|
|
|
|
+ if (A.accountInfo.new_publickey = CT_PublicKey_Nil) then
|
|
|
|
+ Error 'Invalid PASA HLTC, account did not specify an endpoint key';
|
|
|
|
+
|
|
|
|
+ ... implement same consensus rules for as_ForSale, assuming a private sale mode ...
|
|
|
|
+
|
|
|
|
+ // Check hashlock
|
|
|
|
+ if SHA2_256(O.payload) <> A.account_data then
|
|
|
|
+ Error "Hash-locked accounts require correct hash pre-image when purchasing. Purchaser did not provide correct hash pre-image.";
|
|
end;
|
|
end;
|
|
|
|
+
|
|
```
|
|
```
|
|
|
|
|
|
-**NOTE**: An Account Type number must be reserved for _\<HashLocked>_. The reservation of account type numbers is delegated to a future PIP.
|
|
|
|
|
|
+#### Misc Core Changes
|
|
|
|
+
|
|
|
|
+Since a new account state is being introduced, the code-paths for as_ForSale cannot be re-used and must be copied/pasted, or altered to check for this condition. These details are left to the implementor.
|
|
|
|
|
|
## Rationale
|
|
## Rationale
|
|
|
|
|
|
@@ -127,6 +149,11 @@ In conclusion, due to the low cost vs the significant benefits of this change, t
|
|
## Backwards Compatibility
|
|
## Backwards Compatibility
|
|
|
|
|
|
This change is not backwards compatible and requires a hard-fork activation.
|
|
This change is not backwards compatible and requires a hard-fork activation.
|
|
|
|
+
|
|
|
|
+## Acknowledgements
|
|
|
|
+
|
|
|
|
+ * Albert Molina for suggesting use of account state rather than account type.
|
|
|
|
+
|
|
|
|
|
|
## Links
|
|
## Links
|
|
|
|
|