infoblock
Version:
A typed wrapper of the blockchain.info API
51 lines (50 loc) • 2.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionOutput = exports.TransactionInput = void 0;
var Transaction = /** @class */ (function () {
function Transaction(hash, time, fee, height, txInputs, txOutputs) {
this.hash = hash;
this.time = new Date(time * 1000);
this.fee = fee;
this.blockHeight = height;
this.txInputs = txInputs;
this.txOutputs = txOutputs;
}
Transaction.constructFromObj = function (_a) {
var hash = _a.hash, time = _a.time, fee = _a.fee, block_height = _a.block_height, inputs = _a.inputs, out = _a.out;
var txInputs = inputs.map(TransactionInput.constructFromObj);
var txOutputs = out.map(TransactionOutput.constructFromObj);
return new Transaction(hash, time, fee, block_height, txInputs, txOutputs);
};
return Transaction;
}());
exports.default = Transaction;
var TransactionInput = /** @class */ (function () {
function TransactionInput(scriptSig, prevTxOut, witness) {
this.scriptSig = scriptSig;
this.previousTxOutput = prevTxOut;
this.witness = witness;
}
TransactionInput.constructFromObj = function (_a) {
var script = _a.script, prev_out = _a.prev_out, witness = _a.witness;
return prev_out ?
new TransactionInput(script, TransactionOutput.constructFromObj(prev_out)) :
new TransactionInput(script, null, witness);
};
return TransactionInput;
}());
exports.TransactionInput = TransactionInput;
var TransactionOutput = /** @class */ (function () {
function TransactionOutput(amount, scriptPubKey, address, spent) {
this.amount = amount;
this.scriptPubKey = scriptPubKey;
this.address = address;
this.spent = spent;
}
TransactionOutput.constructFromObj = function (_a) {
var value = _a.value, script = _a.script, addr = _a.addr, spent = _a.spent;
return new TransactionOutput(value, script, addr, spent);
};
return TransactionOutput;
}());
exports.TransactionOutput = TransactionOutput;