Skip to content

Commit

Permalink
covenant: set methods on covenant.
Browse files Browse the repository at this point in the history
  • Loading branch information
nodech committed Oct 19, 2023
1 parent 4a70d70 commit ce1c65b
Show file tree
Hide file tree
Showing 19 changed files with 399 additions and 233 deletions.
4 changes: 2 additions & 2 deletions lib/covenants/rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ rules.MAX_COVENANT_SIZE = (0
/**
* Hash a domain name.
* @param {String|Buffer} name
* @returns {Buffer}
* @returns {Hash}
*/

rules.hashName = function hashName(name) {
Expand All @@ -156,7 +156,7 @@ rules.hashName = function hashName(name) {
/**
* Hash a domain name.
* @param {String} name
* @returns {Buffer}
* @returns {Hash}
*/

rules.hashString = function hashString(name) {
Expand Down
2 changes: 1 addition & 1 deletion lib/mempool/mempoolentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class MempoolEntry extends bio.Struct {

/**
* Calculate reverse transaction hash.
* @returns {Hash}
* @returns {HexHash}
*/

txid() {
Expand Down
15 changes: 8 additions & 7 deletions lib/mining/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,14 @@ class BlockTemplate {

output.value = claim.value - claim.fee;
output.address = claim.address;
output.covenant.type = rules.types.CLAIM;
output.covenant.pushHash(claim.nameHash);
output.covenant.pushU32(this.height);
output.covenant.push(claim.name);
output.covenant.pushU8(flags);
output.covenant.pushHash(claim.commitHash);
output.covenant.pushU32(claim.commitHeight);
output.covenant.setClaim(
claim.nameHash,
this.height,
claim.name,
flags,
claim.commitHash,
claim.commitHeight
);

cb.outputs.push(output);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/primitives/address.js
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,8 @@ class Address extends bio.Struct {
if (!data)
throw new Error('Object is not an address.');

if (Buffer.isBuffer(data)) {
if (Buffer.isBuffer(data))
return data;
}

if (data instanceof Address)
return data.hash;
Expand Down
16 changes: 8 additions & 8 deletions lib/primitives/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const InvItem = require('./invitem');
const TX = require('./tx');
const Input = require('./input');
const Output = require('./output');
const {types} = rules;
const {OwnershipProof} = Ownership;

/*
Expand Down Expand Up @@ -170,13 +169,14 @@ class Claim extends bio.Struct {
if (data.weak)
flags |= 1;

output.covenant.type = types.CLAIM;
output.covenant.pushHash(rules.hashName(data.name));
output.covenant.pushU32(height);
output.covenant.pushString(data.name);
output.covenant.pushU8(flags);
output.covenant.pushHash(data.commitHash);
output.covenant.pushU32(data.commitHeight);
output.covenant.setClaim(
rules.hashName(data.name),
height,
Buffer.from(data.name, 'binary'),
flags,
data.commitHash,
data.commitHeight,
);

tx.inputs.push(input);
tx.outputs.push(output);
Expand Down
2 changes: 1 addition & 1 deletion lib/primitives/coin.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Coin extends Output {

/**
* Get little-endian hash.
* @returns {Hash}
* @returns {HexHash?}
*/

txid() {
Expand Down
Loading

0 comments on commit ce1c65b

Please sign in to comment.