@yaswap/yacoin 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.js +3 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/types.d.ts +6 -1
- package/dist/lib/types.js.map +1 -1
- package/dist/lib/wallet/YacoinSingleWallet.d.ts +73 -0
- package/dist/lib/wallet/YacoinSingleWallet.js +714 -0
- package/dist/lib/wallet/YacoinSingleWallet.js.map +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/dist/lib/index.d.ts
CHANGED
|
@@ -11,3 +11,4 @@ export * as YacoinUtils from './utils';
|
|
|
11
11
|
export { YacoinBaseWalletProvider } from './wallet/YacoinBaseWallet';
|
|
12
12
|
export { YacoinHDWalletProvider } from './wallet/YacoinHDWallet';
|
|
13
13
|
export { YacoinNftProvider } from './nft/YacoinNftProvider';
|
|
14
|
+
export { YacoinSingleWallet } from './wallet/YacoinSingleWallet';
|
package/dist/lib/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.YacoinNftProvider = exports.YacoinHDWalletProvider = exports.YacoinBaseWalletProvider = exports.YacoinUtils = exports.YacoinTypes = exports.YacoinSwapEsploraProvider = exports.YacoinSwapBaseProvider = exports.YacoinNetworks = exports.YacoinFeeApiProvider = exports.YacoinEsploraBatchBaseProvider = exports.YacoinEsploraBaseProvider = exports.YacoinEsploraApiProvider = exports.YacoinBaseChainProvider = void 0;
|
|
26
|
+
exports.YacoinSingleWallet = exports.YacoinNftProvider = exports.YacoinHDWalletProvider = exports.YacoinBaseWalletProvider = exports.YacoinUtils = exports.YacoinTypes = exports.YacoinSwapEsploraProvider = exports.YacoinSwapBaseProvider = exports.YacoinNetworks = exports.YacoinFeeApiProvider = exports.YacoinEsploraBatchBaseProvider = exports.YacoinEsploraBaseProvider = exports.YacoinEsploraApiProvider = exports.YacoinBaseChainProvider = void 0;
|
|
27
27
|
var YacoinBaseChainProvider_1 = require("./chain/YacoinBaseChainProvider");
|
|
28
28
|
Object.defineProperty(exports, "YacoinBaseChainProvider", { enumerable: true, get: function () { return YacoinBaseChainProvider_1.YacoinBaseChainProvider; } });
|
|
29
29
|
var YacoinEsploraApiProvider_1 = require("./chain/esplora/YacoinEsploraApiProvider");
|
|
@@ -48,4 +48,6 @@ var YacoinHDWallet_1 = require("./wallet/YacoinHDWallet");
|
|
|
48
48
|
Object.defineProperty(exports, "YacoinHDWalletProvider", { enumerable: true, get: function () { return YacoinHDWallet_1.YacoinHDWalletProvider; } });
|
|
49
49
|
var YacoinNftProvider_1 = require("./nft/YacoinNftProvider");
|
|
50
50
|
Object.defineProperty(exports, "YacoinNftProvider", { enumerable: true, get: function () { return YacoinNftProvider_1.YacoinNftProvider; } });
|
|
51
|
+
var YacoinSingleWallet_1 = require("./wallet/YacoinSingleWallet");
|
|
52
|
+
Object.defineProperty(exports, "YacoinSingleWallet", { enumerable: true, get: function () { return YacoinSingleWallet_1.YacoinSingleWallet; } });
|
|
51
53
|
//# sourceMappingURL=index.js.map
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0E;AAAjE,kIAAA,uBAAuB,OAAA;AAChC,qFAAoF;AAA3E,oIAAA,wBAAwB,OAAA;AACjC,uFAAsF;AAA7E,sIAAA,yBAAyB,OAAA;AAClC,iGAAgG;AAAvF,gJAAA,8BAA8B,OAAA;AACvC,mEAAkE;AAAzD,4HAAA,oBAAoB,OAAA;AAC7B,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,wEAAuE;AAA9D,gIAAA,sBAAsB,OAAA;AAC/B,8EAA6E;AAApE,sIAAA,yBAAyB,OAAA;AAClC,uDAAuC;AACvC,uDAAuC;AACvC,8DAAqE;AAA5D,4HAAA,wBAAwB,OAAA;AACjC,0DAAiE;AAAxD,wHAAA,sBAAsB,OAAA;AAC/B,6DAA4D;AAAnD,sHAAA,iBAAiB,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2EAA0E;AAAjE,kIAAA,uBAAuB,OAAA;AAChC,qFAAoF;AAA3E,oIAAA,wBAAwB,OAAA;AACjC,uFAAsF;AAA7E,sIAAA,yBAAyB,OAAA;AAClC,iGAAgG;AAAvF,gJAAA,8BAA8B,OAAA;AACvC,mEAAkE;AAAzD,4HAAA,oBAAoB,OAAA;AAC7B,uCAA4C;AAAnC,0GAAA,cAAc,OAAA;AACvB,wEAAuE;AAA9D,gIAAA,sBAAsB,OAAA;AAC/B,8EAA6E;AAApE,sIAAA,yBAAyB,OAAA;AAClC,uDAAuC;AACvC,uDAAuC;AACvC,8DAAqE;AAA5D,4HAAA,wBAAwB,OAAA;AACjC,0DAAiE;AAAxD,wHAAA,sBAAsB,OAAA;AAC/B,6DAA4D;AAAnD,sHAAA,iBAAiB,OAAA;AAC1B,kEAAiE;AAAxD,wHAAA,kBAAkB,OAAA"}
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Network, TokenScriptType } from '@yaswap/types';
|
|
3
|
-
import { Network as YacoinJsLibNetwork } from '@yaswap/yacoinjs-lib';
|
|
3
|
+
import { ECPairInterface, Network as YacoinJsLibNetwork } from '@yaswap/yacoinjs-lib';
|
|
4
4
|
export * as YacoinEsploraTypes from './chain/esplora/types';
|
|
5
5
|
export * from './swap/types';
|
|
6
6
|
export interface YacoinNetwork extends Network, YacoinJsLibNetwork {
|
|
@@ -9,6 +9,11 @@ export interface YacoinNodeWalletOptions {
|
|
|
9
9
|
addressType?: AddressType;
|
|
10
10
|
network?: YacoinNetwork;
|
|
11
11
|
}
|
|
12
|
+
export interface YacoinSingleWalletOptions extends YacoinNodeWalletOptions {
|
|
13
|
+
wif?: string;
|
|
14
|
+
publicKey?: Buffer;
|
|
15
|
+
ecpair?: ECPairInterface;
|
|
16
|
+
}
|
|
12
17
|
export interface YacoinWalletProviderOptions extends YacoinNodeWalletOptions {
|
|
13
18
|
baseDerivationPath: string;
|
|
14
19
|
}
|
package/dist/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,4EAA4D;AAC5D,+CAA6B;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,4EAA4D;AAC5D,+CAA6B;AAkF7B,IAAY,WAEX;AAFD,WAAY,WAAW;IACnB,gCAAiB,CAAA;AACrB,CAAC,EAFW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAEtB;AAED,IAAY,QAEX;AAFD,WAAY,QAAQ;IAChB,yBAAa,CAAA;AACjB,CAAC,EAFW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAEnB"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Chain, Wallet } from '@yaswap/client';
|
|
3
|
+
import { Address, AddressType, Asset, BigNumber, Network, Transaction, TransactionRequest, CreateTokenTransaction } from '@yaswap/types';
|
|
4
|
+
import { payments } from '@yaswap/yacoinjs-lib';
|
|
5
|
+
import { ECPairInterface } from 'bitcoinjs-lib';
|
|
6
|
+
import { YacoinBaseChainProvider } from '../chain/YacoinBaseChainProvider';
|
|
7
|
+
import { YacoinNetwork, PsbtInputTarget, Transaction as YacTransaction, OutputTarget, Input, UTXO, YacoinSingleWalletOptions } from '../types';
|
|
8
|
+
import { CoinSelectTarget } from '../utils';
|
|
9
|
+
import { IYacoinWallet } from './IYacoinWallet';
|
|
10
|
+
export declare class YacoinSingleWallet extends Wallet<any, any> implements IYacoinWallet<YacoinBaseChainProvider> {
|
|
11
|
+
private _addressType;
|
|
12
|
+
private _network;
|
|
13
|
+
private _ecpair;
|
|
14
|
+
constructor(options: YacoinSingleWalletOptions, chainProvider?: Chain<YacoinBaseChainProvider>);
|
|
15
|
+
setNetwork(yacoinNetwork: YacoinNetwork): void;
|
|
16
|
+
setECPair(ecpair: ECPairInterface): void;
|
|
17
|
+
setPublicKey(publicKey: Buffer): void;
|
|
18
|
+
setWIF(wif: string): void;
|
|
19
|
+
getUnusedAddress(): Promise<Address>;
|
|
20
|
+
getUsedAddresses(): Promise<Address[]>;
|
|
21
|
+
getAddresses(): Promise<Address[]>;
|
|
22
|
+
createToken(options: CreateTokenTransaction): Promise<Transaction>;
|
|
23
|
+
sendTransaction(options: TransactionRequest): Promise<Transaction<YacTransaction>>;
|
|
24
|
+
sendBatchTransaction(transactions: TransactionRequest[]): Promise<Transaction<YacTransaction>[]>;
|
|
25
|
+
sendSweepTransaction(externalChangeAddress: AddressType, _asset: Asset, feePerByte: number): Promise<Transaction<YacTransaction>>;
|
|
26
|
+
updateTransactionFee(tx: Transaction<YacTransaction> | string, newFeePerByte: number): Promise<Transaction<YacTransaction>>;
|
|
27
|
+
getConnectedNetwork(): Promise<Network>;
|
|
28
|
+
getSigner(): Promise<null>;
|
|
29
|
+
getAddress(): Promise<AddressType>;
|
|
30
|
+
signMessage(message: string): Promise<string>;
|
|
31
|
+
signTx(transaction: string, hash: string, derivationPath: string, txfee: number): Promise<string>;
|
|
32
|
+
getBalance(assets: Asset[]): Promise<BigNumber[]>;
|
|
33
|
+
exportPrivateKey(): Promise<string>;
|
|
34
|
+
isWalletAvailable(): Promise<boolean>;
|
|
35
|
+
canUpdateFee(): boolean;
|
|
36
|
+
signPSBT(data: string, inputs: PsbtInputTarget[]): Promise<string>;
|
|
37
|
+
signBatchP2SHTransaction(inputs: [{
|
|
38
|
+
inputTxHex: string;
|
|
39
|
+
index: number;
|
|
40
|
+
vout: any;
|
|
41
|
+
outputScript: Buffer;
|
|
42
|
+
}], addresses: string, tx: any, locktime: number, segwit?: boolean): Promise<Buffer[]>;
|
|
43
|
+
getWalletAddress(): Promise<Address>;
|
|
44
|
+
getTotalFees(transactions: TransactionRequest[], max: boolean): Promise<any>;
|
|
45
|
+
protected getAddressFromPublicKey(publicKey: Buffer): string;
|
|
46
|
+
protected getPaymentVariantFromPublicKey(publicKey: Buffer): payments.Payment;
|
|
47
|
+
protected withCachedUtxos(func: () => any): Promise<any>;
|
|
48
|
+
protected getTotalFee(opts: TransactionRequest, max: boolean): Promise<number>;
|
|
49
|
+
protected sendOptionsToOutputs(transactions: TransactionRequest[]): OutputTarget[];
|
|
50
|
+
protected tokenInfoToOutputs(transaction: CreateTokenTransaction): OutputTarget[];
|
|
51
|
+
protected compileTokenTransferTarget(address: string, tokenName: string, tokenValue: number): OutputTarget;
|
|
52
|
+
protected compileNewTokenTarget(address: string, tokenName: string, tokenAmount: number, decimals: number, reissuable: Boolean, ipfsHash: string): OutputTarget;
|
|
53
|
+
protected compileTokenOwnerTarget(address: string, ownerTokenName: string): OutputTarget;
|
|
54
|
+
protected compileTimelockFeesTarget(address: string): OutputTarget;
|
|
55
|
+
protected getInputsForAmount(_targets: OutputTarget[], feePerByte?: number, fixedInputs?: Input[], sweep?: boolean): Promise<{
|
|
56
|
+
inputs: UTXO[];
|
|
57
|
+
coinChange: CoinSelectTarget;
|
|
58
|
+
tokenChange: CoinSelectTarget;
|
|
59
|
+
outputs: CoinSelectTarget[];
|
|
60
|
+
fee: number;
|
|
61
|
+
}>;
|
|
62
|
+
protected onChainProviderUpdate(chainProvider: Chain<YacoinBaseChainProvider>): void;
|
|
63
|
+
private dumpPrivKey;
|
|
64
|
+
protected _sendTransaction(transactions: OutputTarget[], feePerByte?: number): Promise<Transaction<YacTransaction>>;
|
|
65
|
+
protected buildTransaction(targets: OutputTarget[], feePerByte?: number, fixedInputs?: Input[]): Promise<{
|
|
66
|
+
hex: string;
|
|
67
|
+
fee: number;
|
|
68
|
+
}>;
|
|
69
|
+
protected buildSweepTransaction(externalChangeAddress: string, feePerByte: number): Promise<{
|
|
70
|
+
hex: string;
|
|
71
|
+
fee: number;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.YacoinSingleWallet = void 0;
|
|
16
|
+
const client_1 = require("@yaswap/client");
|
|
17
|
+
const errors_1 = require("@yaswap/errors");
|
|
18
|
+
const types_1 = require("@yaswap/types");
|
|
19
|
+
const yacoinjs_lib_1 = require("@yaswap/yacoinjs-lib");
|
|
20
|
+
const bitcoinjs_lib_1 = require("bitcoinjs-lib");
|
|
21
|
+
const bitcoinjs_message_1 = require("bitcoinjs-message");
|
|
22
|
+
const types_2 = require("../types");
|
|
23
|
+
const utils_1 = require("../utils");
|
|
24
|
+
const memoizee_1 = __importDefault(require("memoizee"));
|
|
25
|
+
function bigint_to_Buffer(input) {
|
|
26
|
+
const bytesArray = [];
|
|
27
|
+
for (let i = 0; i < 8; i++) {
|
|
28
|
+
let shift = input >> BigInt(8 * i);
|
|
29
|
+
shift &= BigInt(255);
|
|
30
|
+
bytesArray[i] = Number(String(shift));
|
|
31
|
+
}
|
|
32
|
+
return Buffer.from(bytesArray);
|
|
33
|
+
}
|
|
34
|
+
class YacoinSingleWallet extends client_1.Wallet {
|
|
35
|
+
constructor(options, chainProvider) {
|
|
36
|
+
super(chainProvider);
|
|
37
|
+
this._addressType = (options === null || options === void 0 ? void 0 : options.addressType) || types_2.AddressType.LEGACY;
|
|
38
|
+
this._network = chainProvider ? chainProvider.getNetwork() : options.network;
|
|
39
|
+
if (options.ecpair) {
|
|
40
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromPrivateKey(options.ecpair.privateKey, { network: this._network });
|
|
41
|
+
}
|
|
42
|
+
else if (options.wif) {
|
|
43
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromWIF(options.wif, this._network);
|
|
44
|
+
}
|
|
45
|
+
else if (options.publicKey) {
|
|
46
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromPublicKey(options.publicKey, { network: this._network });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
setNetwork(yacoinNetwork) {
|
|
50
|
+
this._network = yacoinNetwork;
|
|
51
|
+
}
|
|
52
|
+
setECPair(ecpair) {
|
|
53
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromPrivateKey(ecpair.privateKey, { network: this._network });
|
|
54
|
+
}
|
|
55
|
+
setPublicKey(publicKey) {
|
|
56
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromPublicKey(publicKey, { network: this._network });
|
|
57
|
+
}
|
|
58
|
+
setWIF(wif) {
|
|
59
|
+
this._ecpair = bitcoinjs_lib_1.ECPair.fromWIF(wif, this._network);
|
|
60
|
+
}
|
|
61
|
+
getUnusedAddress() {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
const address = this.getAddressFromPublicKey(this._ecpair.publicKey);
|
|
64
|
+
const addressObject = new types_1.Address({
|
|
65
|
+
address,
|
|
66
|
+
publicKey: this._ecpair.publicKey.toString('hex'),
|
|
67
|
+
});
|
|
68
|
+
return addressObject;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getUsedAddresses() {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const address = yield this.getUnusedAddress();
|
|
74
|
+
return [address];
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
getAddresses() {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return this.getUsedAddresses();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
createToken(options) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
return this._sendTransaction(this.tokenInfoToOutputs(options), options.fee);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
sendTransaction(options) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
return this._sendTransaction(this.sendOptionsToOutputs([options]), options.fee);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
sendBatchTransaction(transactions) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
return [yield this._sendTransaction(this.sendOptionsToOutputs(transactions))];
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
sendSweepTransaction(externalChangeAddress, _asset, feePerByte) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const { hex, fee } = yield this.buildSweepTransaction(externalChangeAddress.toString(), feePerByte);
|
|
100
|
+
yield this.chainProvider.sendRawTransaction(`data=${hex}`);
|
|
101
|
+
return (0, utils_1.normalizeTransactionObject)((0, utils_1.decodeRawTransaction)(hex, this._network), fee);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
updateTransactionFee(tx, newFeePerByte) {
|
|
105
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
const txHash = typeof tx === 'string' ? tx : tx.hash;
|
|
107
|
+
const transaction = (yield this.chainProvider.getTransactionByHash(txHash))._raw;
|
|
108
|
+
const fixedInputs = [transaction.vin[0]]; // TODO: should this pick more than 1 input? RBF doesn't mandate it
|
|
109
|
+
const changeAddress = yield this.getWalletAddress();
|
|
110
|
+
const changeOutput = transaction.vout.find((vout) => vout.scriptPubKey.addresses[0] === changeAddress.address);
|
|
111
|
+
let outputs = transaction.vout;
|
|
112
|
+
if (changeOutput) {
|
|
113
|
+
outputs = outputs.filter((vout) => vout.scriptPubKey.addresses[0] !== changeOutput.scriptPubKey.addresses[0]);
|
|
114
|
+
}
|
|
115
|
+
// TODO more checks?
|
|
116
|
+
const transactions = outputs.map((output) => ({
|
|
117
|
+
address: output.scriptPubKey.addresses[0],
|
|
118
|
+
value: new types_1.BigNumber(output.value).times(1e6).toNumber(),
|
|
119
|
+
}));
|
|
120
|
+
const { hex, fee } = yield this.buildTransaction(transactions, newFeePerByte, fixedInputs);
|
|
121
|
+
yield this.chainProvider.sendRawTransaction(`data=${hex}`);
|
|
122
|
+
return (0, utils_1.normalizeTransactionObject)((0, utils_1.decodeRawTransaction)(hex, this._network), fee);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
getConnectedNetwork() {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
return this._network;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
getSigner() {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
return null;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
getAddress() {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
const addresses = yield this.getAddresses();
|
|
138
|
+
return addresses[0];
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
signMessage(message) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
const signature = yield (0, bitcoinjs_message_1.signAsync)(message, this._ecpair.privateKey, this._ecpair.compressed);
|
|
144
|
+
return signature.toString('hex');
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
signTx(transaction, hash, derivationPath, txfee) {
|
|
148
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
149
|
+
const result = this._ecpair.sign(Buffer.from(hash, 'hex'));
|
|
150
|
+
return result.toString('hex');
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
getBalance(assets) {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
const addresses = yield this.getAddresses();
|
|
156
|
+
return yield this.chainProvider.getBalance(addresses, assets);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
exportPrivateKey() {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
return this._ecpair.toWIF();
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
isWalletAvailable() {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
return true;
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
canUpdateFee() {
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
172
|
+
signPSBT(data, inputs) {
|
|
173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
174
|
+
// TODO: This doesn't work at the moment, need to implement later
|
|
175
|
+
const psbt = yacoinjs_lib_1.Psbt.fromBase64(data, { network: this._network });
|
|
176
|
+
for (const input of inputs) {
|
|
177
|
+
const usedAddresses = yield this.getUsedAddresses();
|
|
178
|
+
const address = usedAddresses.find((address) => address.derivationPath === input.derivationPath);
|
|
179
|
+
const wif = yield this.dumpPrivKey(address.address);
|
|
180
|
+
const keyPair = bitcoinjs_lib_1.ECPair.fromWIF(wif, this._network);
|
|
181
|
+
psbt.signInput(input.index, keyPair);
|
|
182
|
+
}
|
|
183
|
+
return psbt.toBase64();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
signBatchP2SHTransaction(inputs, addresses, tx, locktime, segwit = false) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
// TODO: This doesn't work at the moment, need to implement later
|
|
189
|
+
const wallets = [];
|
|
190
|
+
for (const address of addresses) {
|
|
191
|
+
const wif = yield this.dumpPrivKey(address);
|
|
192
|
+
const wallet = bitcoinjs_lib_1.ECPair.fromWIF(wif, this._network);
|
|
193
|
+
wallets.push(wallet);
|
|
194
|
+
}
|
|
195
|
+
const sigs = [];
|
|
196
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
197
|
+
let sigHash;
|
|
198
|
+
if (segwit) {
|
|
199
|
+
sigHash = tx.hashForWitnessV0(inputs[i].index, inputs[i].outputScript, inputs[i].vout.vSat, yacoinjs_lib_1.Transaction.SIGHASH_ALL); // AMOUNT NEEDS TO BE PREVOUT AMOUNT
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
sigHash = tx.hashForSignature(inputs[i].index, inputs[i].outputScript, yacoinjs_lib_1.Transaction.SIGHASH_ALL);
|
|
203
|
+
}
|
|
204
|
+
const sig = yacoinjs_lib_1.script.signature.encode(wallets[i].sign(sigHash), yacoinjs_lib_1.Transaction.SIGHASH_ALL);
|
|
205
|
+
sigs.push(sig);
|
|
206
|
+
}
|
|
207
|
+
return sigs;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
getWalletAddress() {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
return yield this.getUnusedAddress();
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
getTotalFees(transactions, max) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
217
|
+
const fees = yield this.withCachedUtxos(() => __awaiter(this, void 0, void 0, function* () {
|
|
218
|
+
const fees = {};
|
|
219
|
+
for (const tx of transactions) {
|
|
220
|
+
const fee = yield this.getTotalFee(tx, max);
|
|
221
|
+
fees[tx.fee] = new types_1.BigNumber(fee);
|
|
222
|
+
}
|
|
223
|
+
return fees;
|
|
224
|
+
}));
|
|
225
|
+
return fees;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
getAddressFromPublicKey(publicKey) {
|
|
229
|
+
return this.getPaymentVariantFromPublicKey(publicKey).address;
|
|
230
|
+
}
|
|
231
|
+
getPaymentVariantFromPublicKey(publicKey) {
|
|
232
|
+
if (this._addressType === types_2.AddressType.LEGACY) {
|
|
233
|
+
return yacoinjs_lib_1.payments.p2pkh({ pubkey: publicKey, network: this._network });
|
|
234
|
+
}
|
|
235
|
+
else
|
|
236
|
+
throw new Error('Unknown script type');
|
|
237
|
+
}
|
|
238
|
+
withCachedUtxos(func) {
|
|
239
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
240
|
+
const originalProvider = this.chainProvider.getProvider();
|
|
241
|
+
const memoizedGetFeePerByte = (0, memoizee_1.default)(originalProvider.getFeePerByte, { primitive: true });
|
|
242
|
+
const memoizedGetUnspentTransactions = (0, memoizee_1.default)(originalProvider.getUnspentTransactions, { primitive: true });
|
|
243
|
+
const memoizedGetAddressTransactionCounts = (0, memoizee_1.default)(originalProvider.getAddressTransactionCounts, {
|
|
244
|
+
primitive: true,
|
|
245
|
+
});
|
|
246
|
+
const newProvider = originalProvider;
|
|
247
|
+
newProvider.getFeePerByte = memoizedGetFeePerByte;
|
|
248
|
+
newProvider.getUnspentTransactions = memoizedGetUnspentTransactions;
|
|
249
|
+
newProvider.getAddressTransactionCounts = memoizedGetAddressTransactionCounts;
|
|
250
|
+
this.chainProvider.setProvider(newProvider);
|
|
251
|
+
const result = yield func.bind(this)();
|
|
252
|
+
this.chainProvider.setProvider(originalProvider);
|
|
253
|
+
return result;
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
getTotalFee(opts, max) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
258
|
+
const targets = this.sendOptionsToOutputs([opts]);
|
|
259
|
+
if (!max) {
|
|
260
|
+
const { fee } = yield this.getInputsForAmount(targets, opts.fee);
|
|
261
|
+
return fee;
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
const { fee } = yield this.getInputsForAmount(targets.filter((t) => !t.value), opts.fee, [], true);
|
|
265
|
+
return fee;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
sendOptionsToOutputs(transactions) {
|
|
270
|
+
const targets = [];
|
|
271
|
+
transactions.forEach((tx) => {
|
|
272
|
+
if (tx.to && tx.value && tx.value.gt(0)) {
|
|
273
|
+
// token/NFT output
|
|
274
|
+
if (tx.asset && tx.asset.type !== 'native') {
|
|
275
|
+
const tokenTransferTarget = this.compileTokenTransferTarget(tx.to.toString(), tx.asset.name.split('|').join('/'), tx.value.toNumber());
|
|
276
|
+
targets.push(tokenTransferTarget);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
// coin output
|
|
281
|
+
targets.push({
|
|
282
|
+
address: tx.to.toString(),
|
|
283
|
+
value: tx.value.toNumber(),
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
if (tx.data) {
|
|
288
|
+
const scriptBuffer = yacoinjs_lib_1.script.compile([yacoinjs_lib_1.script.OPS.OP_RETURN, Buffer.from(tx.data, 'hex')]);
|
|
289
|
+
targets.push({
|
|
290
|
+
value: 0,
|
|
291
|
+
script: scriptBuffer,
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
return targets;
|
|
296
|
+
}
|
|
297
|
+
tokenInfoToOutputs(transaction) {
|
|
298
|
+
var _a;
|
|
299
|
+
const targets = [];
|
|
300
|
+
const tx = transaction;
|
|
301
|
+
// Workaround for displaying sub YA-token
|
|
302
|
+
tx.tokenName = (_a = tx.tokenName) === null || _a === void 0 ? void 0 : _a.split('|').join('/');
|
|
303
|
+
// Create YA-Token
|
|
304
|
+
if (tx.tokenType === types_1.TokenType.token) {
|
|
305
|
+
const subDeliLastIndex = tx.tokenName.lastIndexOf('/');
|
|
306
|
+
if (subDeliLastIndex === -1) {
|
|
307
|
+
// YA-Token
|
|
308
|
+
/*
|
|
309
|
+
YA-Token creation transaction will have
|
|
310
|
+
1) Inputs
|
|
311
|
+
+ Any normal UTXO used as transaction fees + timelock fees
|
|
312
|
+
2) Outputs (at least 3 outputs) with following orders:
|
|
313
|
+
+ Output containing "CSV-P2PKH Timelock script" (random position)
|
|
314
|
+
+ Output containing YAC change (optional, random position)
|
|
315
|
+
+ Output containing "Token Owner Script" (always the second last output)
|
|
316
|
+
+ Output containing "New Token Script" (always the last output)
|
|
317
|
+
*/
|
|
318
|
+
const ownerTokenName = tx.tokenName + '!';
|
|
319
|
+
const timelockFeesTarget = this.compileTimelockFeesTarget(tx.to.toString());
|
|
320
|
+
const tokenOwnerTarget = this.compileTokenOwnerTarget(tx.to.toString(), ownerTokenName);
|
|
321
|
+
const newTokenTarget = this.compileNewTokenTarget(tx.to.toString(), tx.tokenName, tx.tokenAmount, tx.decimals, tx.reissuable, tx.ipfsHash);
|
|
322
|
+
targets.push(timelockFeesTarget);
|
|
323
|
+
targets.push(tokenOwnerTarget);
|
|
324
|
+
targets.push(newTokenTarget);
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
// sub YA-Token
|
|
328
|
+
/*
|
|
329
|
+
sub YA-Token creation transaction will have
|
|
330
|
+
1) Inputs
|
|
331
|
+
+ owner token UTXO
|
|
332
|
+
+ Any normal UTXO used as transaction fees + timelock fees
|
|
333
|
+
2) Outputs (at least 4 outputs) with following orders:
|
|
334
|
+
+ Output containing "CSV-P2PKH Timelock script" (random position)
|
|
335
|
+
+ Output containing "Transfer Token Owner Script" (random position)
|
|
336
|
+
+ Output containing YAC change (optional, random position)
|
|
337
|
+
+ Output containing "Token Owner Script" (always the second last output)
|
|
338
|
+
+ Output containing "New Token Script" (always the last output)
|
|
339
|
+
*/
|
|
340
|
+
const ownerTokenName = tx.tokenName.slice(0, subDeliLastIndex) + '!';
|
|
341
|
+
const subOwnerTokenName = tx.tokenName + '!';
|
|
342
|
+
const timelockFeesTarget = this.compileTimelockFeesTarget(tx.to.toString());
|
|
343
|
+
const tokenTransferTarget = this.compileTokenTransferTarget(tx.to.toString(), ownerTokenName, 1e6);
|
|
344
|
+
const tokenOwnerTarget = this.compileTokenOwnerTarget(tx.to.toString(), subOwnerTokenName);
|
|
345
|
+
const newTokenTarget = this.compileNewTokenTarget(tx.to.toString(), tx.tokenName, tx.tokenAmount, tx.decimals, tx.reissuable, tx.ipfsHash);
|
|
346
|
+
targets.push(timelockFeesTarget);
|
|
347
|
+
targets.push(tokenTransferTarget);
|
|
348
|
+
targets.push(tokenOwnerTarget);
|
|
349
|
+
targets.push(newTokenTarget);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
else {
|
|
353
|
+
// Create YA-NFT
|
|
354
|
+
/*
|
|
355
|
+
YA-NFT creation transaction will have
|
|
356
|
+
1) Inputs
|
|
357
|
+
+ owner token UTXO
|
|
358
|
+
+ Any normal UTXO used as transaction fees + timelock fees
|
|
359
|
+
2) Outputs (at least 3 outputs) with following orders:
|
|
360
|
+
+ Output containing "CSV-P2PKH Timelock script" (random position)
|
|
361
|
+
+ Output containing "Transfer Token Owner Script" (random position)
|
|
362
|
+
+ Output containing YAC change (optional, random position)
|
|
363
|
+
+ Output containing "New Token Script" (always the last output)
|
|
364
|
+
*/
|
|
365
|
+
const ownerTokenName = tx.tokenName.split('#')[0] + '!';
|
|
366
|
+
const timelockFeesTarget = this.compileTimelockFeesTarget(tx.to.toString());
|
|
367
|
+
const tokenTransferTarget = this.compileTokenTransferTarget(tx.to.toString(), ownerTokenName, 1e6);
|
|
368
|
+
const newTokenTarget = this.compileNewTokenTarget(tx.to.toString(), tx.tokenName, tx.tokenAmount, tx.decimals, tx.reissuable, tx.ipfsHash);
|
|
369
|
+
targets.push(timelockFeesTarget);
|
|
370
|
+
targets.push(tokenTransferTarget);
|
|
371
|
+
targets.push(newTokenTarget);
|
|
372
|
+
}
|
|
373
|
+
return targets;
|
|
374
|
+
}
|
|
375
|
+
compileTokenTransferTarget(address, tokenName, tokenValue) {
|
|
376
|
+
/*
|
|
377
|
+
OP_DUP OP_HASH160 <hash_of_public_key> OP_EQUALVERIFY OP_CHECKSIG < OP_YAC_TOKEN << YACT << token_name << token_amount << OP_DROP
|
|
378
|
+
|
|
379
|
+
OP_DUP = 0x76
|
|
380
|
+
OP_HASH160 = 0xa9
|
|
381
|
+
1 bytes for length of hash public key
|
|
382
|
+
20 bytes hash of public key
|
|
383
|
+
OP_EQUALVERIFY = 0x88
|
|
384
|
+
OP_CHECKSIG = 0xac
|
|
385
|
+
OP_YAC_TOKEN = 0xb3
|
|
386
|
+
1 byte for length of asset script excluding OP_DROP
|
|
387
|
+
#define YAC_Y 121 (0x79)
|
|
388
|
+
#define YAC_A 97 (0x61)
|
|
389
|
+
#define YAC_C 99 (0x63)
|
|
390
|
+
#define YAC_T 116 (0x74)
|
|
391
|
+
1 byte for length of token name
|
|
392
|
+
token name
|
|
393
|
+
8 bytes of token amount (little endian)
|
|
394
|
+
OP_DROP = 0x75
|
|
395
|
+
*/
|
|
396
|
+
const recipientPubKeyHash = (0, utils_1.getPubKeyHash)(address, this._network);
|
|
397
|
+
const yactBuffer = Buffer.alloc(4);
|
|
398
|
+
yactBuffer.writeUInt32BE(0x79616374, 0);
|
|
399
|
+
const tokenNameBuf = Buffer.from(tokenName, 'utf-8');
|
|
400
|
+
const tokenNameLenBuf = Buffer.alloc(1);
|
|
401
|
+
tokenNameLenBuf.writeUInt8(tokenNameBuf.length, 0);
|
|
402
|
+
const tokenAmountBuf = bigint_to_Buffer(BigInt(tokenValue));
|
|
403
|
+
const tokenTransferScriptBuf = Buffer.concat([yactBuffer, tokenNameLenBuf, tokenNameBuf, tokenAmountBuf]);
|
|
404
|
+
const scriptBuffer = yacoinjs_lib_1.script.compile([
|
|
405
|
+
yacoinjs_lib_1.script.OPS.OP_DUP,
|
|
406
|
+
yacoinjs_lib_1.script.OPS.OP_HASH160,
|
|
407
|
+
recipientPubKeyHash,
|
|
408
|
+
yacoinjs_lib_1.script.OPS.OP_EQUALVERIFY,
|
|
409
|
+
yacoinjs_lib_1.script.OPS.OP_CHECKSIG,
|
|
410
|
+
yacoinjs_lib_1.script.OPS.OP_NOP4,
|
|
411
|
+
tokenTransferScriptBuf,
|
|
412
|
+
yacoinjs_lib_1.script.OPS.OP_DROP,
|
|
413
|
+
]);
|
|
414
|
+
return {
|
|
415
|
+
value: 0,
|
|
416
|
+
token_value: tokenValue,
|
|
417
|
+
script: scriptBuffer,
|
|
418
|
+
tokenName,
|
|
419
|
+
tokenScriptType: types_1.TokenScriptType.transfer,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
compileNewTokenTarget(address, tokenName, tokenAmount, decimals, reissuable, ipfsHash) {
|
|
423
|
+
/*
|
|
424
|
+
OP_DUP OP_HASH160 <hash_of_public_key> OP_EQUALVERIFY OP_CHECKSIG < OP_YAC_TOKEN << YACQ << token_name << token_amount << units << reissuable << IPFS_Hash << OP_DROP
|
|
425
|
+
|
|
426
|
+
OP_DUP = 0x76
|
|
427
|
+
OP_HASH160 = 0xa9
|
|
428
|
+
1 bytes for length of hash public key
|
|
429
|
+
20 bytes hash of public key
|
|
430
|
+
OP_EQUALVERIFY = 0x88
|
|
431
|
+
OP_CHECKSIG = 0xac
|
|
432
|
+
OP_YAC_TOKEN = 0xb3
|
|
433
|
+
1 byte for length of asset script excluding OP_DROP
|
|
434
|
+
#define YAC_Y 121 (0x79)
|
|
435
|
+
#define YAC_A 97 (0x61)
|
|
436
|
+
#define YAC_C 99 (0x63)
|
|
437
|
+
#define YAC_Q 113 (0x71)
|
|
438
|
+
1 byte for length of token name
|
|
439
|
+
token name
|
|
440
|
+
8 bytes of token amount (little endian)
|
|
441
|
+
1 byte of units
|
|
442
|
+
1 byte of reissuable
|
|
443
|
+
1 byte of hasIPFS
|
|
444
|
+
34 bytes of IPFS hash (CID v1)
|
|
445
|
+
OP_DROP = 0x75
|
|
446
|
+
*/
|
|
447
|
+
const recipientPubKeyHash = (0, utils_1.getPubKeyHash)(address, this._network);
|
|
448
|
+
const yacqBuffer = Buffer.alloc(4);
|
|
449
|
+
yacqBuffer.writeUInt32BE(0x79616371, 0);
|
|
450
|
+
const tokenNameBuf = Buffer.from(tokenName, 'utf-8');
|
|
451
|
+
const tokenNameLenBuf = Buffer.alloc(1);
|
|
452
|
+
tokenNameLenBuf.writeUInt8(tokenNameBuf.length, 0);
|
|
453
|
+
const tokenAmountBuf = bigint_to_Buffer(BigInt(tokenAmount));
|
|
454
|
+
let newTokenScriptArr = [yacqBuffer, tokenNameLenBuf, tokenNameBuf, tokenAmountBuf];
|
|
455
|
+
const unitReissuableHasIPFSBuf = Buffer.alloc(3);
|
|
456
|
+
unitReissuableHasIPFSBuf.writeUInt8(decimals, 0);
|
|
457
|
+
unitReissuableHasIPFSBuf.writeUInt8(Number(reissuable), 1);
|
|
458
|
+
if (ipfsHash) {
|
|
459
|
+
unitReissuableHasIPFSBuf.writeUInt8(1, 2);
|
|
460
|
+
const ipfsHashBuf = Buffer.from(ipfsHash, 'hex');
|
|
461
|
+
newTokenScriptArr.push(unitReissuableHasIPFSBuf);
|
|
462
|
+
newTokenScriptArr.push(ipfsHashBuf);
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
unitReissuableHasIPFSBuf.writeUInt8(0, 2);
|
|
466
|
+
newTokenScriptArr.push(unitReissuableHasIPFSBuf);
|
|
467
|
+
}
|
|
468
|
+
const newTokenScriptBuf = Buffer.concat(newTokenScriptArr);
|
|
469
|
+
const scriptBuffer = yacoinjs_lib_1.script.compile([
|
|
470
|
+
yacoinjs_lib_1.script.OPS.OP_DUP,
|
|
471
|
+
yacoinjs_lib_1.script.OPS.OP_HASH160,
|
|
472
|
+
recipientPubKeyHash,
|
|
473
|
+
yacoinjs_lib_1.script.OPS.OP_EQUALVERIFY,
|
|
474
|
+
yacoinjs_lib_1.script.OPS.OP_CHECKSIG,
|
|
475
|
+
yacoinjs_lib_1.script.OPS.OP_NOP4,
|
|
476
|
+
newTokenScriptBuf,
|
|
477
|
+
yacoinjs_lib_1.script.OPS.OP_DROP,
|
|
478
|
+
]);
|
|
479
|
+
return {
|
|
480
|
+
value: 0,
|
|
481
|
+
token_value: tokenAmount,
|
|
482
|
+
script: scriptBuffer,
|
|
483
|
+
tokenName,
|
|
484
|
+
tokenScriptType: types_1.TokenScriptType.newToken,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
compileTokenOwnerTarget(address, ownerTokenName) {
|
|
488
|
+
/*
|
|
489
|
+
OP_DUP OP_HASH160 <hash_of_public_key> OP_EQUALVERIFY OP_CHECKSIG < OP_YAC_TOKEN << YACO << token_owner_name << OP_DROP
|
|
490
|
+
|
|
491
|
+
OP_DUP = 0x76
|
|
492
|
+
OP_HASH160 = 0xa9
|
|
493
|
+
1 bytes for length of hash public key
|
|
494
|
+
20 bytes hash of public key
|
|
495
|
+
OP_EQUALVERIFY = 0x88
|
|
496
|
+
OP_CHECKSIG = 0xac
|
|
497
|
+
OP_YAC_TOKEN = 0xb3
|
|
498
|
+
1 byte for length of asset script excluding OP_DROP
|
|
499
|
+
#define YAC_Y 121 (0x79)
|
|
500
|
+
#define YAC_A 97 (0x61)
|
|
501
|
+
#define YAC_C 99 (0x63)
|
|
502
|
+
#define YAC_O 111 (0x6F)
|
|
503
|
+
1 byte for length of token owner name
|
|
504
|
+
token owner name
|
|
505
|
+
OP_DROP = 0x75
|
|
506
|
+
*/
|
|
507
|
+
const recipientPubKeyHash = (0, utils_1.getPubKeyHash)(address, this._network);
|
|
508
|
+
const yacoBuffer = Buffer.alloc(4);
|
|
509
|
+
yacoBuffer.writeUInt32BE(0x7961636f, 0);
|
|
510
|
+
const tokenNameBuf = Buffer.from(ownerTokenName, 'utf-8');
|
|
511
|
+
const tokenNameLenBuf = Buffer.alloc(1);
|
|
512
|
+
tokenNameLenBuf.writeUInt8(tokenNameBuf.length, 0);
|
|
513
|
+
const tokenOwnerScriptBuf = Buffer.concat([yacoBuffer, tokenNameLenBuf, tokenNameBuf]);
|
|
514
|
+
const scriptBuffer = yacoinjs_lib_1.script.compile([
|
|
515
|
+
yacoinjs_lib_1.script.OPS.OP_DUP,
|
|
516
|
+
yacoinjs_lib_1.script.OPS.OP_HASH160,
|
|
517
|
+
recipientPubKeyHash,
|
|
518
|
+
yacoinjs_lib_1.script.OPS.OP_EQUALVERIFY,
|
|
519
|
+
yacoinjs_lib_1.script.OPS.OP_CHECKSIG,
|
|
520
|
+
yacoinjs_lib_1.script.OPS.OP_NOP4,
|
|
521
|
+
tokenOwnerScriptBuf,
|
|
522
|
+
yacoinjs_lib_1.script.OPS.OP_DROP,
|
|
523
|
+
]);
|
|
524
|
+
return {
|
|
525
|
+
value: 0,
|
|
526
|
+
token_value: 1e6,
|
|
527
|
+
script: scriptBuffer,
|
|
528
|
+
tokenName: ownerTokenName,
|
|
529
|
+
tokenScriptType: types_1.TokenScriptType.tokenOwner,
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
compileTimelockFeesTarget(address) {
|
|
533
|
+
/*
|
|
534
|
+
|
|
535
|
+
<locktime> OP_CHECKSEQUENCEVERIFY OP_DROP OP_DUP OP_HASH160 <hash_of_public_key> OP_EQUALVERIFY OP_CHECKSIG
|
|
536
|
+
*/
|
|
537
|
+
const recipientPubKeyHash = (0, utils_1.getPubKeyHash)(address, this._network);
|
|
538
|
+
const scriptBuffer = yacoinjs_lib_1.script.compile([
|
|
539
|
+
yacoinjs_lib_1.script.number.encode((0, utils_1.timelockFeeDuration)()),
|
|
540
|
+
yacoinjs_lib_1.script.OPS.OP_CHECKSEQUENCEVERIFY,
|
|
541
|
+
yacoinjs_lib_1.script.OPS.OP_DROP,
|
|
542
|
+
yacoinjs_lib_1.script.OPS.OP_DUP,
|
|
543
|
+
yacoinjs_lib_1.script.OPS.OP_HASH160,
|
|
544
|
+
recipientPubKeyHash,
|
|
545
|
+
yacoinjs_lib_1.script.OPS.OP_EQUALVERIFY,
|
|
546
|
+
yacoinjs_lib_1.script.OPS.OP_CHECKSIG,
|
|
547
|
+
]);
|
|
548
|
+
return {
|
|
549
|
+
value: (0, utils_1.timelockFeeAmountInSatoshis)(),
|
|
550
|
+
script: scriptBuffer,
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
getInputsForAmount(_targets, feePerByte, fixedInputs = [], sweep = false) {
|
|
554
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
555
|
+
const tokenTransferOutput = _targets.find((target) => target.tokenName !== undefined && target.tokenScriptType === types_1.TokenScriptType.transfer);
|
|
556
|
+
const feePerBytePromise = this.chainProvider.getProvider().getFeePerByte();
|
|
557
|
+
let utxos = [];
|
|
558
|
+
let tokenUtxos = [];
|
|
559
|
+
const addresses = yield this.getUsedAddresses();
|
|
560
|
+
const fixedUtxos = [];
|
|
561
|
+
if (fixedInputs.length > 0) {
|
|
562
|
+
for (const input of fixedInputs) {
|
|
563
|
+
const txHex = yield this.chainProvider.getProvider().getRawTransactionByHash(input.txid);
|
|
564
|
+
const tx = (0, utils_1.decodeRawTransaction)(txHex, this._network);
|
|
565
|
+
const value = new types_1.BigNumber(tx.vout[input.vout].value).times(1e6).toNumber();
|
|
566
|
+
const address = tx.vout[input.vout].scriptPubKey.addresses[0];
|
|
567
|
+
const utxo = Object.assign(Object.assign({}, input), { value, address });
|
|
568
|
+
fixedUtxos.push(utxo);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
if (!sweep || fixedUtxos.length === 0) {
|
|
572
|
+
const _utxos = yield this.chainProvider.getProvider().getUnspentTransactions(addresses);
|
|
573
|
+
utxos.push(..._utxos.map((utxo) => {
|
|
574
|
+
const addr = addresses.find((a) => a.address === utxo.address);
|
|
575
|
+
return Object.assign(Object.assign({}, utxo), { derivationPath: addr.derivationPath });
|
|
576
|
+
}));
|
|
577
|
+
}
|
|
578
|
+
else {
|
|
579
|
+
utxos = fixedUtxos;
|
|
580
|
+
}
|
|
581
|
+
if (tokenTransferOutput) {
|
|
582
|
+
const isNFTOutput = tokenTransferOutput.tokenName.indexOf('#') !== -1;
|
|
583
|
+
const _utxos = isNFTOutput
|
|
584
|
+
? yield this.chainProvider.getProvider().getNFTUnspentTransactions(addresses, tokenTransferOutput.tokenName)
|
|
585
|
+
: yield this.chainProvider.getProvider().getTokenUnspentTransactions(addresses, tokenTransferOutput.tokenName);
|
|
586
|
+
tokenUtxos.push(..._utxos.map((utxo) => {
|
|
587
|
+
const addr = addresses.find((a) => a.address === utxo.address);
|
|
588
|
+
return Object.assign(Object.assign({}, utxo), { derivationPath: addr.derivationPath });
|
|
589
|
+
}));
|
|
590
|
+
}
|
|
591
|
+
const utxoBalance = utxos.reduce((a, b) => a + (b.value || 0), 0);
|
|
592
|
+
if (!feePerByte)
|
|
593
|
+
feePerByte = yield feePerBytePromise;
|
|
594
|
+
const minRelayFee = yield this.chainProvider.getProvider().getMinRelayFee();
|
|
595
|
+
if (feePerByte < minRelayFee) {
|
|
596
|
+
throw new Error(`Fee supplied (${feePerByte} sat/b) too low. Minimum relay fee is ${minRelayFee} sat/b`);
|
|
597
|
+
}
|
|
598
|
+
let targets;
|
|
599
|
+
if (sweep) {
|
|
600
|
+
const outputBalance = _targets.reduce((a, b) => a + (b['value'] || 0), 0);
|
|
601
|
+
const sweepOutputSize = 39;
|
|
602
|
+
const paymentOutputSize = _targets.filter((t) => t.value && t.address).length * 39;
|
|
603
|
+
const scriptOutputSize = _targets
|
|
604
|
+
.filter((t) => !t.value && t.script)
|
|
605
|
+
.reduce((size, t) => size + 39 + t.script.byteLength, 0);
|
|
606
|
+
const outputSize = sweepOutputSize + paymentOutputSize + scriptOutputSize;
|
|
607
|
+
const inputSize = utxos.length * 153;
|
|
608
|
+
const sweepFee = feePerByte * (inputSize + outputSize);
|
|
609
|
+
const amountToSend = new types_1.BigNumber(utxoBalance).minus(sweepFee);
|
|
610
|
+
targets = _targets.map((target) => ({
|
|
611
|
+
id: 'main',
|
|
612
|
+
value: target.value,
|
|
613
|
+
script: target.script,
|
|
614
|
+
tokenName: target.tokenName,
|
|
615
|
+
token_value: target.token_value,
|
|
616
|
+
tokenScriptType: target.tokenScriptType,
|
|
617
|
+
}));
|
|
618
|
+
targets.push({ id: 'main', value: amountToSend.minus(outputBalance).toNumber() });
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
targets = _targets.map((target) => ({
|
|
622
|
+
id: 'main',
|
|
623
|
+
value: target.value,
|
|
624
|
+
script: target.script,
|
|
625
|
+
tokenName: target.tokenName,
|
|
626
|
+
token_value: target.token_value,
|
|
627
|
+
tokenScriptType: target.tokenScriptType,
|
|
628
|
+
}));
|
|
629
|
+
}
|
|
630
|
+
const { inputs, outputs, fee, coinChange, tokenChange } = (0, utils_1.selectCoins)(utxos, tokenUtxos, targets, Math.ceil(feePerByte), fixedUtxos);
|
|
631
|
+
if (inputs && outputs) {
|
|
632
|
+
return {
|
|
633
|
+
inputs,
|
|
634
|
+
coinChange,
|
|
635
|
+
tokenChange,
|
|
636
|
+
outputs,
|
|
637
|
+
fee,
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
throw new errors_1.InsufficientBalanceError('Not enough balance');
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
onChainProviderUpdate(chainProvider) {
|
|
644
|
+
this._network = chainProvider.getNetwork();
|
|
645
|
+
}
|
|
646
|
+
dumpPrivKey(address) {
|
|
647
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
return this.chainProvider.sendRpcRequest('dumpprivkey', [address]);
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
_sendTransaction(transactions, feePerByte) {
|
|
652
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
653
|
+
const { hex, fee } = yield this.buildTransaction(transactions, feePerByte);
|
|
654
|
+
const result = yield this.chainProvider.sendRawTransaction(`data=${hex}`);
|
|
655
|
+
if (result == 'There was an error. Check your console.') {
|
|
656
|
+
throw new Error("Cannot send transaction, there might some reasons:\n 1) It might be the fee is not enough, please try increasing the fee.\n 2) The wallet haven't updated latest balance info, please wait 10 seconds and try again.");
|
|
657
|
+
}
|
|
658
|
+
return (0, utils_1.normalizeTransactionObject)((0, utils_1.decodeRawTransaction)(hex, this._network), fee);
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
buildTransaction(targets, feePerByte, fixedInputs) {
|
|
662
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
663
|
+
const network = this._network;
|
|
664
|
+
const unusedAddress = yield this.getUnusedAddress();
|
|
665
|
+
const { inputs, coinChange, tokenChange, fee } = yield this.getInputsForAmount(targets, feePerByte, fixedInputs);
|
|
666
|
+
if (coinChange) {
|
|
667
|
+
targets.unshift({
|
|
668
|
+
address: unusedAddress.address,
|
|
669
|
+
value: coinChange.value,
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
if (tokenChange) {
|
|
673
|
+
const tokenTransferTarget = this.compileTokenTransferTarget(unusedAddress.address, tokenChange.tokenName, tokenChange.token_value);
|
|
674
|
+
targets.unshift(tokenTransferTarget);
|
|
675
|
+
}
|
|
676
|
+
var tx = new yacoinjs_lib_1.TransactionBuilder(network);
|
|
677
|
+
// Add input
|
|
678
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
679
|
+
tx.addInput(inputs[i].txid, inputs[i].vout);
|
|
680
|
+
}
|
|
681
|
+
// Add output
|
|
682
|
+
for (const output of targets) {
|
|
683
|
+
if (output.script) {
|
|
684
|
+
tx.addOutput(output.script, output.value);
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
tx.addOutput(output.address, output.value);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
// Sign transaction
|
|
691
|
+
for (let i = 0; i < inputs.length; i++) {
|
|
692
|
+
tx.sign(i, this._ecpair, inputs[i]);
|
|
693
|
+
}
|
|
694
|
+
return { hex: tx.build().toHex(), fee };
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
buildSweepTransaction(externalChangeAddress, feePerByte) {
|
|
698
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
699
|
+
let _feePerByte = feePerByte || null; // TODO: fix me
|
|
700
|
+
if (!_feePerByte) {
|
|
701
|
+
_feePerByte = yield this.chainProvider.getProvider().getFeePerByte();
|
|
702
|
+
}
|
|
703
|
+
const { inputs, outputs, coinChange } = yield this.getInputsForAmount([], _feePerByte, [], true);
|
|
704
|
+
if (coinChange) {
|
|
705
|
+
throw new Error('There should not be any change for sweeping transaction');
|
|
706
|
+
}
|
|
707
|
+
const _outputs = [{ address: externalChangeAddress, value: outputs[0].value }];
|
|
708
|
+
// TODO: fix the inherited legacy code
|
|
709
|
+
return this.buildTransaction(_outputs, feePerByte, inputs);
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
exports.YacoinSingleWallet = YacoinSingleWallet;
|
|
714
|
+
//# sourceMappingURL=YacoinSingleWallet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YacoinSingleWallet.js","sourceRoot":"","sources":["../../../lib/wallet/YacoinSingleWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAA0D;AAC1D,yCAWuB;AACvB,uDAM8B;AAC9B,iDAGuB;AACvB,yDAAmE;AAEnE,oCASkB;AAClB,oCAQkB;AAElB,wDAA+B;AAE/B,SAAS,gBAAgB,CAAC,KAAa;IACrC,MAAM,UAAU,GAAG,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE;QAC1B,IAAI,KAAK,GAAG,KAAK,IAAI,MAAM,CAAC,CAAC,GA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CAAC;QACnF,CAAC;KAAA;CACF;AA5xBD,gDA4xBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yaswap/yacoin",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Yaswap",
|
|
6
6
|
"homepage": "",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"@types/bitcoinjs-lib": "^5.0.0",
|
|
21
21
|
"@types/lodash": "^4.14.178",
|
|
22
22
|
"@types/memoizee": "^0.4.7",
|
|
23
|
-
"@yaswap/client": "2.7.
|
|
24
|
-
"@yaswap/errors": "2.7.
|
|
25
|
-
"@yaswap/types": "2.7.
|
|
26
|
-
"@yaswap/utils": "2.7.
|
|
23
|
+
"@yaswap/client": "2.7.2",
|
|
24
|
+
"@yaswap/errors": "2.7.2",
|
|
25
|
+
"@yaswap/types": "2.7.2",
|
|
26
|
+
"@yaswap/utils": "2.7.2",
|
|
27
27
|
"@yaswap/yacoinjs-coinselect": "^1.1.0",
|
|
28
28
|
"@yaswap/yacoinjs-lib": "^1.3.0",
|
|
29
29
|
"bip174": "^2.0.1",
|