-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #122 from Bitcoin-com/next
- Loading branch information
Showing
190 changed files
with
3,631 additions
and
2,900 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
pragma cashscript ^0.6.0; | ||
pragma cashscript ^0.7.0; | ||
|
||
/* This is a contract showcasing covenants outside of regular transactional use. | ||
* It enforces the contract to make an "announcement" on Memo.cash, and send the | ||
* remainder of contract funds back to the contract. | ||
*/ | ||
contract Announcement() { | ||
function announce(pubkey pk, sig s) { | ||
require(checkSig(s, pk)); | ||
|
||
function announce() { | ||
// Create the memo.cash announcement output | ||
bytes announcement = new OutputNullData([ | ||
bytes announcement = new LockingBytecodeNullData([ | ||
0x6d02, | ||
bytes('A contract may not injure a human being or, through inaction, allow a human being to come to harm.') | ||
]); | ||
|
||
// Calculate leftover money after fee (2000 sats) | ||
// Add change output if the remainder can be used | ||
// otherwise donate the remainder to the miner | ||
int minerFee = 2000; | ||
int changeAmount = int(bytes(tx.value)) - minerFee; | ||
if (changeAmount >= (minerFee / 2)) { | ||
bytes32 change = new OutputP2SH(bytes8(changeAmount), hash160(tx.bytecode)); | ||
require(tx.hashOutputs == hash256(announcement + change)); | ||
} else { | ||
require(tx.hashOutputs == hash256(announcement)); | ||
// Check that the first tx output matches the announcement | ||
require(tx.outputs[0].value == 0); | ||
require(tx.outputs[0].lockingBytecode == announcement); | ||
|
||
// Calculate leftover money after fee (1000 sats) | ||
// Check that the second tx output sends the change back if there's enough leftover for another announcement | ||
int minerFee = 1000; | ||
int changeAmount = tx.inputs[this.activeInputIndex].value - minerFee; | ||
if (changeAmount >= minerFee) { | ||
require(tx.outputs[1].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode); | ||
require(tx.outputs[1].value == changeAmount); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pragma cashscript ^0.6.0; | ||
pragma cashscript ^0.7.0; | ||
|
||
contract TransferWithTimeout( | ||
pubkey sender, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.