本文整理汇总了C++中SecretKey::getPublicKey方法的典型用法代码示例。如果您正苦于以下问题:C++ SecretKey::getPublicKey方法的具体用法?C++ SecretKey::getPublicKey怎么用?C++ SecretKey::getPublicKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SecretKey
的用法示例。
在下文中一共展示了SecretKey::getPublicKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadAccount
TestAccount
TestAccount::create(SecretKey const& secretKey, uint64_t initialBalance)
{
auto toCreate = loadAccount(secretKey.getPublicKey(), mApp, false);
auto self = loadAccount(getSecretKey().getPublicKey(), mApp);
try
{
applyTx(tx({createAccount(secretKey.getPublicKey(), initialBalance)}),
mApp);
}
catch (...)
{
auto toCreateAfter = loadAccount(secretKey.getPublicKey(), mApp, false);
// check that the target account didn't change
REQUIRE(!!toCreate == !!toCreateAfter);
if (toCreate && toCreateAfter)
{
REQUIRE(toCreate->getAccount() == toCreateAfter->getAccount());
}
throw;
}
REQUIRE(loadAccount(secretKey.getPublicKey(), mApp));
return TestAccount{mApp, secretKey};
}
示例2: delta
static void
createTestAccounts(Application& app, int nbAccounts,
std::function<int64(int)> getBalance,
std::function<int(int)> getVote)
{
// set up world
SecretKey root = getRoot();
SequenceNumber rootSeq = getAccountSeqNum(root, app) + 1;
auto& lm = app.getLedgerManager();
auto& db = app.getDatabase();
int64 setupBalance = lm.getMinBalance(0);
LedgerDelta delta(lm.getCurrentLedgerHeader());
for (int i = 0; i < nbAccounts; i++)
{
int64 bal = getBalance(i);
if (bal >= 0)
{
SecretKey to = getTestAccount(i);
applyPaymentTx(app, root, to, rootSeq++, setupBalance);
AccountFrame act;
REQUIRE(AccountFrame::loadAccount(to.getPublicKey(), act, db));
act.getAccount().balance = bal;
act.getAccount().inflationDest.activate() =
getTestAccount(getVote(i)).getPublicKey();
act.storeChange(delta, db);
}
}
}
示例3:
Simulation::pointer
Topologies::hierarchicalQuorumSimplified(int coreSize, int nbOuterNodes,
Simulation::Mode mode,
Hash const& networkID,
std::function<Config()> confGen)
{
// outer nodes are independent validators that point to a [core network]
auto sim = Topologies::core(coreSize, 0.75, mode, networkID, confGen);
// each additional node considers themselves as validator
// with a quorum set that also includes the core
int n = coreSize + 1;
SCPQuorumSet qSetBuilder;
qSetBuilder.threshold = n - (n - 1) / 3;
vector<NodeID> coreNodeIDs;
for (auto const& coreNodeID : sim->getNodeIDs())
{
qSetBuilder.validators.push_back(coreNodeID);
coreNodeIDs.emplace_back(coreNodeID);
}
qSetBuilder.validators.emplace_back();
for (int i = 0; i < nbOuterNodes; i++)
{
SecretKey sk =
SecretKey::fromSeed(sha256("OUTER_NODE_SEED_" + to_string(i)));
auto const& pubKey = sk.getPublicKey();
qSetBuilder.validators.back() = pubKey;
sim->addNode(sk, qSetBuilder, sim->getClock());
// connect it to one of the core nodes
sim->addPendingConnection(pubKey, coreNodeIDs[i % coreSize]);
}
return sim;
}
示例4: bytes
void
LedgerManagerImpl::startNewLedger()
{
auto ledgerTime = mLedgerClose.TimeScope();
ByteSlice bytes("allmylifemyhearthasbeensearching");
SecretKey skey = SecretKey::fromSeed(bytes);
AccountFrame masterAccount(skey.getPublicKey());
masterAccount.getAccount().balance = 100000000000000000;
LedgerHeader genesisHeader;
// all fields are initialized by default to 0
// set the ones that are not 0
genesisHeader.baseFee = 10;
genesisHeader.baseReserve = 10000000;
genesisHeader.totalCoins = masterAccount.getAccount().balance;
genesisHeader.ledgerSeq = 1;
LedgerDelta delta(genesisHeader);
masterAccount.storeAdd(delta, this->getDatabase());
delta.commit();
mCurrentLedger = make_shared<LedgerHeaderFrame>(genesisHeader);
CLOG(INFO, "Ledger") << "Established genesis ledger, closing";
closeLedgerHelper(delta);
}
示例5: REQUIRE
uint64_t
getAccountBalance(SecretKey const& k, Application& app)
{
AccountFrame account;
REQUIRE(AccountFrame::loadAccount(k.getPublicKey(), account,
app.getDatabase()));
return account.getBalance();
}
示例6: delta
void
applyPaymentTx(Application& app, SecretKey& from, SecretKey& to,
SequenceNumber seq, int64_t amount, PaymentResultCode result)
{
TransactionFramePtr txFrame;
AccountFrame fromAccount;
AccountFrame toAccount;
bool beforeToExists = AccountFrame::loadAccount(
to.getPublicKey(), toAccount, app.getDatabase());
REQUIRE(AccountFrame::loadAccount(from.getPublicKey(), fromAccount,
app.getDatabase()));
txFrame = createPaymentTx(from, to, seq, amount);
LedgerDelta delta(app.getLedgerManager().getCurrentLedgerHeader());
txFrame->apply(delta, app);
checkTransaction(*txFrame);
auto txResult = txFrame->getResult();
auto innerCode = PaymentOpFrame::getInnerCode(txResult.result.results()[0]);
REQUIRE(innerCode == result);
REQUIRE(txResult.feeCharged == app.getLedgerManager().getTxFee());
AccountFrame toAccountAfter;
bool afterToExists = AccountFrame::loadAccount(
to.getPublicKey(), toAccountAfter, app.getDatabase());
if (!(innerCode == PAYMENT_SUCCESS || innerCode == PAYMENT_SUCCESS_MULTI))
{
// check that the target account didn't change
REQUIRE(beforeToExists == afterToExists);
if (beforeToExists && afterToExists)
{
REQUIRE(memcmp(&toAccount.getAccount(),
&toAccountAfter.getAccount(),
sizeof(AccountEntry)) == 0);
}
}
else
{
REQUIRE(afterToExists);
}
}
示例7: getHint
DecoratedSignature
sign(SecretKey const& secretKey, Hash const& hash)
{
DecoratedSignature result;
result.signature = secretKey.sign(hash);
result.hint = getHint(secretKey.getPublicKey().ed25519());
return result;
}
示例8: strToCurrencyCode
Currency
makeCurrency(SecretKey& issuer, std::string const& code)
{
Currency currency;
currency.type(CURRENCY_TYPE_ALPHANUM);
currency.alphaNum().issuer = issuer.getPublicKey();
strToCurrencyCode(currency.alphaNum().currencyCode, code);
return currency;
}
示例9: clearCached
void
TransactionFrame::addSignature(SecretKey const& secretKey)
{
clearCached();
DecoratedSignature sig;
sig.signature = secretKey.sign(getContentsHash());
memcpy(&sig.hint, secretKey.getPublicKey().data(), sizeof(sig.hint));
mEnvelope.signatures.push_back(sig);
}
示例10:
SequenceNumber
getSeq(SecretKey const& k, Application& app)
{
AccountFrame::pointer account;
account = AccountFrame::loadAccount(k.getPublicKey(), app.getDatabase());
if (account)
{
return account->getSeqNum();
}
return 0;
}
示例11: transactionFromOperation
TransactionFramePtr
createPaymentTx(SecretKey& from, SecretKey& to, SequenceNumber seq,
int64_t amount)
{
Operation op;
op.body.type(PAYMENT);
op.body.paymentOp().amount = amount;
op.body.paymentOp().destination = to.getPublicKey();
op.body.paymentOp().sendMax = INT64_MAX;
op.body.paymentOp().currency.type(CURRENCY_TYPE_NATIVE);
return transactionFromOperation(from, seq, op);
}
示例12: mNodeID
LocalNode::LocalNode(SecretKey const& secretKey, bool isValidator,
SCPQuorumSet const& qSet, SCP* scp)
: mNodeID(secretKey.getPublicKey())
, mSecretKey(secretKey)
, mIsValidator(isValidator)
, mQSet(qSet)
, mSCP(scp)
{
adjustQSet(mQSet);
mQSetHash = sha256(xdr::xdr_to_opaque(mQSet));
CLOG(INFO, "SCP") << "LocalNode::LocalNode"
<< "@" << PubKeyUtils::toShortString(mNodeID)
<< " qSet: " << hexAbbrev(mQSetHash);
mSingleQSet = std::make_shared<SCPQuorumSet>(buildSingletonQSet(mNodeID));
gSingleQSetHash = sha256(xdr::xdr_to_opaque(*mSingleQSet));
}
示例13:
TransactionFramePtr
transactionFromOperation(SecretKey& from, SequenceNumber seq,
Operation const& op)
{
TransactionEnvelope e;
e.tx.sourceAccount = from.getPublicKey();
e.tx.maxLedger = UINT32_MAX;
e.tx.minLedger = 0;
e.tx.fee = 10;
e.tx.seqNum = seq;
e.tx.operations.push_back(op);
TransactionFramePtr res = TransactionFrame::makeTransactionFromWire(e);
res->addSignature(from);
return res;
}
示例14: ls
TestAccount
TestAccount::create(SecretKey const& secretKey, uint64_t initialBalance)
{
auto publicKey = secretKey.getPublicKey();
std::unique_ptr<LedgerEntry> destBefore;
{
LedgerState ls(mApp.getLedgerStateRoot());
auto entry = stellar::loadAccount(ls, publicKey);
if (entry)
{
destBefore = std::make_unique<LedgerEntry>(entry.current());
}
}
try
{
applyTx(tx({createAccount(publicKey, initialBalance)}), mApp);
}
catch (...)
{
LedgerState ls(mApp.getLedgerStateRoot());
auto destAfter = stellar::loadAccount(ls, publicKey);
// check that the target account didn't change
REQUIRE(!!destBefore == !!destAfter);
if (destBefore && destAfter)
{
REQUIRE(*destBefore == destAfter.current());
}
throw;
}
{
LedgerState ls(mApp.getLedgerStateRoot());
REQUIRE(stellar::loadAccount(ls, publicKey));
}
return TestAccount{mApp, secretKey};
}
示例15: applyChangeTrust
// can't lower the limit below balance
applyChangeTrust(app, root, gateway, rootSeq++, "IDR", 89,
CHANGE_TRUST_INVALID_LIMIT);
// can't delete if there is a balance
applyChangeTrust(app, root, gateway, rootSeq++, "IDR", 0,
CHANGE_TRUST_INVALID_LIMIT);
// lower the limit at the balance
applyChangeTrust(app, root, gateway, rootSeq++, "IDR", 90);
// clear the balance
applyCreditPaymentTx(app, root, gateway, idrCur, rootSeq++, 90);
// delete the trust line
applyChangeTrust(app, root, gateway, rootSeq++, "IDR", 0);
REQUIRE(!(TrustFrame::loadTrustLine(root.getPublicKey(), idrCur, db)));
}
SECTION("issuer does not exist")
{
SECTION("new trust line")
{
applyChangeTrust(app, root, gateway, rootSeq, "USD", 100,
CHANGE_TRUST_NO_ISSUER);
}
SECTION("edit existing")
{
const int64_t minBalance2 = app.getLedgerManager().getMinBalance(2);
applyCreateAccountTx(app, root, gateway, rootSeq++, minBalance2);
SequenceNumber gateway_seq = getAccountSeqNum(gateway, app) + 1;